ChangeSet 1.1807.48.1, 2004/07/30 16:33:20-07:00, [EMAIL PROTECTED]

[PATCH] USB: Fix NULL-pointer bug in dummy_hcd

This patch fixes a NULL-pointer-dereference bug in the dummy_hcd driver.
It also makes the code slightly more elegant and removes an unnecessary
buffer-overflow test.  Unfortunately it's still a little bit racy, but
this is a fault it shares with other gadget controller drivers, like
net2280.

Signed-off-by: Alan Stern <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 drivers/usb/gadget/dummy_hcd.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)


diff -Nru a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
--- a/drivers/usb/gadget/dummy_hcd.c    2004-08-23 13:22:16 -07:00
+++ b/drivers/usb/gadget/dummy_hcd.c    2004-08-23 13:22:16 -07:00
@@ -596,14 +596,13 @@
 
 /* "function" sysfs attribute */
 static ssize_t
-show_function (struct device *_dev, char *buf)
+show_function (struct device *dev, char *buf)
 {
-       struct dummy    *dum = the_controller;
+       struct dummy    *dum = gadget_dev_to_dummy (dev);
 
-       if (!dum->driver->function
-                       || strlen (dum->driver->function) > PAGE_SIZE)
+       if (!dum->driver || !dum->driver->function)
                return 0;
-       return snprintf (buf, PAGE_SIZE, "%s\n", dum->driver->function);
+       return scnprintf (buf, PAGE_SIZE, "%s\n", dum->driver->function);
 }
 DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
 



-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to