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
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 @@ static char *usb_dump_interface_descriptor(char *start, char *end, const struct
desc->bInterfaceSubClass,
desc->bInterfaceProtocol,
iface->driver ? iface->driver->name : "(none)");
unlock_kernel();
up_read(&usb_bus_type.subsys.rwsem);
return start;
}
......
......@@ -374,13 +374,15 @@ static int claimintf(struct dev_state *ps, unsigned int intf)
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 @@ static int releaseintf(struct dev_state *ps, unsigned int intf)
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;
}
......
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