]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
i40iw: Add missing NULL check for MPA private data
authorShiraz Saleem <shiraz.saleem@intel.com>
Mon, 22 Aug 2016 23:16:37 +0000 (18:16 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Oct 2016 13:21:20 +0000 (15:21 +0200)
commit 5dfd5e5e3bc68ab3912acc712c8180942094fc69 upstream.

Add NULL check for pdata and pdata->addr before the memcpy in
i40iw_form_cm_frame(). This fixes a NULL pointer de-reference
which occurs when the MPA private data pointer is NULL. Also
only copy pdata->size bytes in the memcpy to prevent reading
past the length of the private data buffer provided by upper layer.

Fixes: f27b4746f378 ("i40iw: add connection management code")
Reported-by: Stefan Assmann <sassmann@redhat.com>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/infiniband/hw/i40iw/i40iw_cm.c

index d2fa7251696077a3fb3f7b8cec5955bd9348a603..d2f6a068c60ed1d38578dc07b71306d4b223648c 100644 (file)
@@ -535,8 +535,8 @@ static struct i40iw_puda_buf *i40iw_form_cm_frame(struct i40iw_cm_node *cm_node,
                buf += hdr_len;
        }
 
-       if (pd_len)
-               memcpy(buf, pdata->addr, pd_len);
+       if (pdata && pdata->addr)
+               memcpy(buf, pdata->addr, pdata->size);
 
        atomic_set(&sqbuf->refcount, 1);