Greg:

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.

Please apply.

Alan Stern



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

===== drivers/usb/gadget/dummy_hcd.c 1.11 vs edited =====
--- 1.11/drivers/usb/gadget/dummy_hcd.c Wed Jun 30 12:33:55 2004
+++ edited/drivers/usb/gadget/dummy_hcd.c       Thu Jul 29 12:10:55 2004
@@ -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);
 



-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to