Hi, All:

I found (or, rather, our users found and I confirmed) that if a disconnect
happens at the right time, cat /proc/bus/usb/devices is likely to crash.
It can fail in several places, but mostly it's related to a references
to struct usb_device which was freed.

It looks that this problem was addressed in 2.6, but I do not wish to
backport everything. The attached patch makes it to go away in my case.
I suspect that it may be still racy, so I'm pondering if I should send
this to Marcelo. Any comments?

-- Pete

diff -urp -X dontdiff linux-2.4.28-pre3/drivers/usb/devices.c 
linux-2.4.28-pre3-usb/drivers/usb/devices.c
--- linux-2.4.28-pre3/drivers/usb/devices.c     2004-09-12 14:24:09.000000000 -0700
+++ linux-2.4.28-pre3-usb/drivers/usb/devices.c 2004-10-05 13:54:14.000000000 -0700
@@ -552,9 +552,13 @@ static ssize_t usb_device_dump(char **bu
        
        /* Now look at all of this device's children. */
        for (chix = 0; chix < usbdev->maxchild; chix++) {
-               if (usbdev->children[chix]) {
-                       ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, 
usbdev->children[chix],
+               struct usb_device *childdev = usbdev->children[chix];
+               if (childdev) {
+                       usb_inc_dev_use(childdev);
+                       ret = usb_device_dump(buffer, nbytes, skip_bytes,
+                                       file_offset, childdev,
                                        bus, level + 1, chix, ++cnt);
+                       usb_dec_dev_use(childdev);
                        if (ret == -EFAULT)
                                return total_written;
                        total_written += ret;


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to