Browse Source

Staging: rtl8712: fix potential null pointer dereference

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>
Matteo Semenzato 10 years ago
parent
commit
66faa441a6
1 changed files with 2 additions and 0 deletions
  1. 2 0
      drivers/staging/rtl8712/rtl871x_mlme.c

+ 2 - 0
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