]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: core: bail out if user gives an unknown RefId when using new_id
authorWolfram Sang <wsa@the-dreams.de>
Sun, 12 Jan 2014 09:07:50 +0000 (10:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Jan 2014 00:09:35 +0000 (16:09 -0800)
If users use the new RefId feature of new_id, give them an error message
if they provided an unknown reference. That helps detecting typos.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/core/driver.c

index 9b29e5c94be7d36e68cfe19f6a5154a539b180af..620a0baf103e1c2017865fa586e984010430e860 100644 (file)
@@ -74,10 +74,13 @@ ssize_t usb_store_new_id(struct usb_dynids *dynids,
                const struct usb_device_id *id = id_table;
 
                for (; id->match_flags; id++)
-                       if (id->idVendor == refVendor && id->idProduct == refProduct) {
-                               dynid->id.driver_info = id->driver_info;
+                       if (id->idVendor == refVendor && id->idProduct == refProduct)
                                break;
-                       }
+
+               if (id->match_flags)
+                       dynid->id.driver_info = id->driver_info;
+               else
+                       return -ENODEV;
        }
 
        spin_lock(&dynids->lock);