From: Matteo Semenzato <mattew8...@gmail.com>

Check if kmalloc succeded before using the pointer in memcpy.

Signed-off-by: Matteo Semenzato <mattew8...@gmail.com>
---
 drivers/staging/rtl8712/rtl871x_mlme.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c 
b/drivers/staging/rtl8712/rtl871x_mlme.c
index 977a833..c6e9012 100644
--- a/drivers/staging/rtl8712/rtl871x_mlme.c
+++ b/drivers/staging/rtl8712/rtl871x_mlme.c
@@ -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
-- 
2.3.2

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to