diff mbox series

[BACKPORT,4.4.y,15/25] usb: gadget: composite: fix dereference after null check coverify warning

Message ID 20190322154425.3852517-16-arnd@arndb.de
State New
Headers show
Series candidates from spreadtrum 4.4 product kernel | expand

Commit Message

Arnd Bergmann March 22, 2019, 3:44 p.m. UTC
From: Peter Chen <peter.chen@nxp.com>


cdev->config is checked for null pointer at above code, so cdev->config
might be null, fix it by adding null pointer check.

Signed-off-by: Peter Chen <peter.chen@nxp.com>

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>

(cherry picked from commit c526c62d565ea5a5bba9433f28756079734f430d)
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/usb/gadget/composite.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.20.0
diff mbox series

Patch

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 58f5fbdb6959..8bf54477f472 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1819,6 +1819,8 @@  unknown:
 			break;
 
 		case USB_RECIP_ENDPOINT:
+			if (!cdev->config)
+				break;
 			endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);
 			list_for_each_entry(f, &cdev->config->functions, list) {
 				if (test_bit(endp, f->endpoints))