staging: btmtk_usb: check for a valid io_buf pointer
authorDevendra Naga <devendra.aaru@gmail.com>
Sun, 26 May 2013 03:04:16 +0000 (23:04 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 May 2013 12:02:06 +0000 (21:02 +0900)
assigned to retval of kmalloc but not checked whether the allocation failed or not,
fail the registering if allocation fail

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/btmtk_usb/btmtk_usb.c

index 85bafacbb2fd343c367a461393063e78dd81f0c4..ab57a4b97e69bb1c9eedd2e67aa56a934de9f23c 100644 (file)
@@ -1597,6 +1597,11 @@ static int btmtk_usb_probe(struct usb_interface *intf,
        }
 
        data->io_buf = kmalloc(256, GFP_ATOMIC);
+       if (!data->io_buf) {
+               hci_free_dev(hdev);
+               kfree(data);
+               return -ENOMEM;
+       }
 
        btmtk_usb_switch_iobase(data, WLAN);