Staging: rtl8712: fix potential null pointer dereference
authorMatteo Semenzato <mattew8898@gmail.com>
Wed, 11 Mar 2015 13:31:14 +0000 (14:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Mar 2015 14:48:20 +0000 (15:48 +0100)
Check if kmalloc succeded before using the pointer in memcpy.

Signed-off-by: Matteo Semenzato <mattew8898@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8712/rtl871x_mlme.c

index 9b13de1437a109178e643d8a1a91757056c25955..fb2b195b90af0d1690552dfccb6ec93b13960fdf 100644 (file)
@@ -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