Skip to contentSkip to conversation

Staging: rtl8712: fix potential null pointer dereference

PATCH New Matteo Semenzato 1 participant 1 message Mar 11, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8712: fix potential null pointer dereference

From: Matteo Semenzato <[email protected]>

Check if kmalloc succeded before using the pointer in memcpy.

---
 drivers/staging/rtl8712/rtl871x_mlme.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/rtl8712/rtl871x_mlme.c +2 -0
index 977a833..c6e9012 100644
@@ -727,6 +727,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
Signature · 1 line
2.3.2