Skip to contentSkip to conversation

gadget: possible null pointer dereference fix

PATCH In review Cerrato Renaud 2 participants 4 messages Mar 13, 2013 – Mar 14, 2013 USB

lore
Share & tools
lore
#0 lore raw

PATCH 4/5 gadget: possible null pointer dereference fix

This patch fix a possible null pointer dereference exception because of a missing null check on cdev->config

---
 drivers/usb/gadget/composite.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
drivers/usb/gadget/composite.c +13 -10
index 9af115e..1f6c5b2 100644
@@ -777,18 +777,21 @@ unknown:
          * recipients (endpoint, other, WUSB, ...) to the current
          * configuration code.
          */
-        f = cdev->config->interface[intf];
-        if (f && f->setup)
-            value = f->setup(f, ctrl);
-        else
-            f = NULL;
+        if(cdev->config) {
 
-        if (value < 0 && !f) {
-            struct usb_configuration    *c;
+            f = cdev->config->interface[intf];
+            if (f && f->setup)
+                value = f->setup(f, ctrl);
+            else
+                f = NULL;
 
-            c = cdev->config;
-            if (c && c->setup)
-                value = c->setup(c, ctrl);
+            if (value < 0 && !f) {
+                struct usb_configuration    *c;
+
+                c = cdev->config;
+                if (c && c->setup)
+                    value = c->setup(c, ctrl);
+            }
         }
 
         goto done;
Signature · 7 lines
1.7.2.5


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 12 lines · Cerrato Renaud

This patch fix a possible null pointer dereference exception because of a missing null check on cdev->config

---
 drivers/usb/gadget/composite.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
drivers/usb/gadget/composite.c +0 -0
index 9af115e..1f6c5b2 100644

drivers/usb/gadget/composite.c unknown: · line 780

Quoted 9 lines
drivers/usb/gadget/composite.c +1 -5
@@ -777,18 +777,21 @@ unknown:
          * recipients (endpoint, other, WUSB, ...) to the current
          * configuration code.
          */
-        f = cdev->config->interface[intf];
-        if (f && f->setup)
-            value = f->setup(f, ctrl);
-        else
-            f = NULL;
+        if(cdev->config) {

please do a:

	if (!cdev->config)
		goto out;

instead.

Your patch is whitespace damaged, I won't be able to apply it. As Jean-Christophe mentioned, you should use git-send-mail for sending your patches. It does things just right.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

For some reasons relative to my company , I'm not able to send emails using git-send-email. I gave up.
Thanks.

Quoted 28 lines · Sascha Hauer
Quoted 12 lines · Cerrato Renaud

This patch fix a possible null pointer dereference exception because of a missing null check on cdev->config

---
 drivers/usb/gadget/composite.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
drivers/usb/gadget/composite.c +0 -0
index 9af115e..1f6c5b2 100644

drivers/usb/gadget/composite.c unknown: · line 780

Quoted 9 lines
drivers/usb/gadget/composite.c +1 -5
@@ -777,18 +777,21 @@ unknown:
          * recipients (endpoint, other, WUSB, ...) to the current
          * configuration code.
          */
-        f = cdev->config->interface[intf];
-        if (f && f->setup)
-            value = f->setup(f, ctrl);
-        else
-            f = NULL;
+        if(cdev->config) {

please do a:

	if (!cdev->config)
		goto out;
Quoted 8 lines

instead.

Your patch is whitespace damaged, I won't be able to apply it. As Jean-Christophe mentioned, you should use git-send-mail for sending your patches. It does things just right.

Sascha

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#3 lore raw
Quoted 2 lines · Cerrato Renaud

For some reasons relative to my company , I'm not able to send emails using git-send-email. I gave up.

What a pitty.

I know getting the tools right for sending patches can be quite a high barrier sometimes. Most other Open Source projects will require the same if you want to participate, so I think it's really worth it to set this up, if it's not for barebox then it might be for the Kernel or whatever project you might be interested in.

Most other people in your situation setup a Gmail account and end up sending mails from home if necessary until they can put enough pressure on their administrators.

Sorry, I don't like loosing useful contributions, but on the other hand our workflow depends on being able to review and apply patches quickly.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox