Commit eea93a30 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[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).
parent 6f58f120
...@@ -238,7 +238,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end, const struct ...@@ -238,7 +238,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end, const struct
if (start > end) if (start > end)
return start; return start;
lock_kernel(); /* driver might be unloaded */ down_read(&usb_bus_type.subsys.rwsem);
start += sprintf(start, format_iface, start += sprintf(start, format_iface,
desc->bInterfaceNumber, desc->bInterfaceNumber,
desc->bAlternateSetting, desc->bAlternateSetting,
...@@ -248,7 +248,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end, const struct ...@@ -248,7 +248,7 @@ static char *usb_dump_interface_descriptor(char *start, char *end, const struct
desc->bInterfaceSubClass, desc->bInterfaceSubClass,
desc->bInterfaceProtocol, desc->bInterfaceProtocol,
iface->driver ? iface->driver->name : "(none)"); iface->driver ? iface->driver->name : "(none)");
unlock_kernel(); up_read(&usb_bus_type.subsys.rwsem);
return start; return start;
} }
......
...@@ -374,13 +374,15 @@ static int claimintf(struct dev_state *ps, unsigned int intf) ...@@ -374,13 +374,15 @@ static int claimintf(struct dev_state *ps, unsigned int intf)
return 0; return 0;
iface = dev->actconfig->interface[intf]; iface = dev->actconfig->interface[intf];
err = -EBUSY; err = -EBUSY;
lock_kernel();
/* lock against other changes to driver bindings */
down_write(&usb_bus_type.subsys.rwsem);
if (!usb_interface_claimed(iface)) { if (!usb_interface_claimed(iface)) {
usb_driver_claim_interface(&usbdevfs_driver, iface, ps); usb_driver_claim_interface(&usbdevfs_driver, iface, ps);
set_bit(intf, &ps->ifclaimed); set_bit(intf, &ps->ifclaimed);
err = 0; err = 0;
} }
unlock_kernel(); up_write(&usb_bus_type.subsys.rwsem);
return err; return err;
} }
...@@ -395,11 +397,14 @@ static int releaseintf(struct dev_state *ps, unsigned int intf) ...@@ -395,11 +397,14 @@ static int releaseintf(struct dev_state *ps, unsigned int intf)
err = -EINVAL; err = -EINVAL;
dev = ps->dev; dev = ps->dev;
down(&dev->serialize); 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)) { if (test_and_clear_bit(intf, &ps->ifclaimed)) {
iface = dev->actconfig->interface[intf]; iface = dev->actconfig->interface[intf];
usb_driver_release_interface(&usbdevfs_driver, iface); usb_driver_release_interface(&usbdevfs_driver, iface);
err = 0; err = 0;
} }
up_write(&usb_bus_type.subsys.rwsem);
up(&dev->serialize); up(&dev->serialize);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment