ChangeSet 1.1673.8.44, 2004/03/30 08:53:38-08:00, [EMAIL PROTECTED]

[PATCH] USB; minor usbfs locking updates

These are "obvious" locking fixes:  using the right lock
to protect interface claim/release (should be the driver
model bus lock, not BKL).


 drivers/usb/core/devices.c |    4 ++--
 drivers/usb/core/devio.c   |    9 +++++++--
 2 files changed, 9 insertions(+), 4 deletions(-)


diff -Nru a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
--- a/drivers/usb/core/devices.c        Wed Apr 14 14:36:30 2004
+++ b/drivers/usb/core/devices.c        Wed Apr 14 14:36:30 2004
@@ -238,7 +238,7 @@
 
        if (start > end)
                return start;
-       lock_kernel(); /* driver might be unloaded */
+       down_read(&usb_bus_type.subsys.rwsem);
        start += sprintf(start, format_iface,
                         desc->bInterfaceNumber,
                         desc->bAlternateSetting,
@@ -248,7 +248,7 @@
                         desc->bInterfaceSubClass,
                         desc->bInterfaceProtocol,
                         iface->driver ? iface->driver->name : "(none)");
-       unlock_kernel();
+       up_read(&usb_bus_type.subsys.rwsem);
        return start;
 }
 
diff -Nru a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
--- a/drivers/usb/core/devio.c  Wed Apr 14 14:36:30 2004
+++ b/drivers/usb/core/devio.c  Wed Apr 14 14:36:30 2004
@@ -374,13 +374,15 @@
                return 0;
        iface = dev->actconfig->interface[intf];
        err = -EBUSY;
-       lock_kernel();
+
+       /* lock against other changes to driver bindings */
+       down_write(&usb_bus_type.subsys.rwsem);
        if (!usb_interface_claimed(iface)) {
                usb_driver_claim_interface(&usbdevfs_driver, iface, ps);
                set_bit(intf, &ps->ifclaimed);
                err = 0;
        }
-       unlock_kernel();
+       up_write(&usb_bus_type.subsys.rwsem);
        return err;
 }
 
@@ -395,11 +397,14 @@
        err = -EINVAL;
        dev = ps->dev;
        down(&dev->serialize);
+       /* lock against other changes to driver bindings */
+       down_write(&usb_bus_type.subsys.rwsem);
        if (test_and_clear_bit(intf, &ps->ifclaimed)) {
                iface = dev->actconfig->interface[intf];
                usb_driver_release_interface(&usbdevfs_driver, iface);
                err = 0;
        }
+       up_write(&usb_bus_type.subsys.rwsem);
        up(&dev->serialize);
        return err;
 }



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to