]> Pileus Git - ~andy/linux/blobdiff - drivers/net/usb/smsc95xx.c
smsc95xx: fix suspend buffer overflow
[~andy/linux] / drivers / net / usb / smsc95xx.c
index 79d495d155469cb306155e339a7246358e35d407..c397b3a04f10a676a45a988104d3b50aa750da88 100644 (file)
@@ -1281,7 +1281,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
        }
 
        if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) {
-               u32 *filter_mask = kzalloc(32, GFP_KERNEL);
+               u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL);
                u32 command[2];
                u32 offset[2];
                u32 crc[4];
@@ -1290,6 +1290,11 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
                        LAN9500A_WUFF_NUM : LAN9500_WUFF_NUM;
                int i, filter = 0;
 
+               if (!filter_mask) {
+                       netdev_warn(dev->net, "Unable to allocate filter_mask\n");
+                       return -ENOMEM;
+               }
+
                memset(command, 0, sizeof(command));
                memset(offset, 0, sizeof(offset));
                memset(crc, 0, sizeof(crc));