Driver probings and interface claims could rejected
if an interface is not authorized.

Signed-off-by: Stefan Koch <sk...@suse.de>
---
 drivers/base/base.h       |  1 -
 drivers/usb/core/driver.c | 11 +++++++++++
 include/linux/device.h    |  1 +
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/base/base.h b/drivers/base/base.h
index 251c5d3..4b304a8 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -102,7 +102,6 @@ extern void container_dev_init(void);
 struct kobject *virtual_device_parent(struct device *dev);
 
 extern int bus_add_device(struct device *dev);
-extern void bus_probe_device(struct device *dev);
 extern void bus_remove_device(struct device *dev);
 
 extern int bus_add_driver(struct device_driver *drv);
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 818369a..9d4251f 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -295,6 +295,13 @@ static int usb_probe_interface(struct device *dev)
        if (udev->authorized == 0) {
                dev_err(&intf->dev, "Device is not authorized for usage\n");
                return error;
+       } else if (intf->authorized == 0) {
+               unsigned intfNr = intf->altsetting->desc.bInterfaceNumber;
+
+               dev_err(&intf->dev, "Interface 0x%02x is not authorized for 
usage\n",
+                               intfNr);
+
+               return error;
        }
 
        id = usb_match_dynamic_id(intf, driver);
@@ -507,6 +514,10 @@ int usb_driver_claim_interface(struct usb_driver *driver,
        if (dev->driver)
                return -EBUSY;
 
+       /* reject claim if not iterface is not authorized */
+       if (!iface->authorized)
+               return -ENODEV;
+
        udev = interface_to_usbdev(iface);
 
        dev->driver = &driver->drvwrap.driver;
diff --git a/include/linux/device.h b/include/linux/device.h
index 6558af9..598d282 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -976,6 +976,7 @@ extern void device_release_driver(struct device *dev);
 extern int  __must_check device_attach(struct device *dev);
 extern int __must_check driver_attach(struct device_driver *drv);
 extern int __must_check device_reprobe(struct device *dev);
+extern void bus_probe_device(struct device *dev);
 
 /*
  * Easy functions for dynamically creating devices on the fly
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to