[PATCH] staging: btmtk_usb: check for a valid io_buf pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---

Hello, 

Seems that kmalloc is called with GFP_ATOMIC flag
which is in registering stage, as since there wont be any interrupt context in this path,
may i change it to GFP_KERNEL in a subsequent patch?

Thanks
 drivers/staging/btmtk_usb/btmtk_usb.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/btmtk_usb/btmtk_usb.c b/drivers/staging/btmtk_usb/btmtk_usb.c
index 85bafac..ab57a4b 100644
--- a/drivers/staging/btmtk_usb/btmtk_usb.c
+++ b/drivers/staging/btmtk_usb/btmtk_usb.c
@@ -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);
 
-- 
1.7.11.7

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




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux