diff mbox series

bluetooth: btusb: check for NULL in btusb_find_altsetting()

Message ID 20200408052703.7351-1-sathish.narasimman@intel.com (mailing list archive)
State Accepted
Delegated to: Marcel Holtmann
Headers show
Series bluetooth: btusb: check for NULL in btusb_find_altsetting() | expand

Commit Message

Sathish Narasimman April 8, 2020, 5:27 a.m. UTC
The new btusb_find_altsetting() dereferences it without checking
the check is added in this patch

Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
---
 drivers/bluetooth/btusb.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Marcel Holtmann April 8, 2020, 6:17 a.m. UTC | #1
Hi Satish,

> The new btusb_find_altsetting() dereferences it without checking
> the check is added in this patch
> 
> Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
> ---
> drivers/bluetooth/btusb.c | 3 +++
> 1 file changed, 3 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 110e96b245e5..2e715a6232dc 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1622,6 +1622,9 @@  static struct usb_host_interface *btusb_find_altsetting(struct btusb_data *data,
 
 	BT_DBG("Looking for Alt no :%d", alt);
 
+	if (!intf)
+		return NULL;
+
 	for (i = 0; i < intf->num_altsetting; i++) {
 		if (intf->altsetting[i].desc.bAlternateSetting == alt)
 			return &intf->altsetting[i];