]> git.sur5r.net Git - u-boot/commitdiff
usb: gadget: composite: fix NULL pointer when a non standard request is received
authorChristophe Kerello <christophe.kerello@st.com>
Thu, 15 Mar 2018 08:34:17 +0000 (09:34 +0100)
committerMarek Vasut <marex@denx.de>
Thu, 26 Apr 2018 13:15:07 +0000 (15:15 +0200)
In case usb configuration is unknown (cdev->config == NULL), non standard
request should not be processed.
Remove also the cdev->config check below which will never happen.

This issue was seen using ums feature.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
drivers/usb/gadget/composite.c

index d0ee7847b98dbb98dd2e220e741009a3a107ba5b..a87639def97433366e1b6218169c55f6ef6ba43b 100644 (file)
@@ -838,6 +838,9 @@ unknown:
                        ctrl->bRequestType, ctrl->bRequest,
                        w_value, w_index, w_length);
 
+               if (!cdev->config)
+                       goto done;
+
                /*
                 * functions always handle their interfaces and endpoints...
                 * punt other recipients (other, WUSB, ...) to the current
@@ -882,7 +885,7 @@ unknown:
                        value = f->setup(f, ctrl);
                else {
                        c = cdev->config;
-                       if (c && c->setup)
+                       if (c->setup)
                                value = c->setup(c, ctrl);
                }