From: Matteo Semenzato Date: Wed, 11 Mar 2015 13:31:14 +0000 (+0100) Subject: Staging: rtl8712: fix potential null pointer dereference X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=66faa441a6f5753dd3e7add3e1640819ba9ec1c2;p=openwrt%2Fstaging%2Fblogic.git Staging: rtl8712: fix potential null pointer dereference Check if kmalloc succeded before using the pointer in memcpy. Signed-off-by: Matteo Semenzato Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 9b13de1437a1..fb2b195b90af 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -725,6 +725,8 @@ void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf) if (sizeof(struct list_head) == 4 * sizeof(u32)) { pnetwork = kmalloc(sizeof(struct wlan_network), GFP_ATOMIC); + if (!pnetwork) + return; memcpy((u8 *)pnetwork+16, (u8 *)pbuf + 8, sizeof(struct wlan_network) - 16); } else