From: Wolfram Sang Date: Sun, 12 Jan 2014 09:07:50 +0000 (+0100) Subject: usb: core: bail out if user gives an unknown RefId when using new_id X-Git-Tag: next-20140116~16^2~9 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=52a6966c;p=karo-tx-linux.git usb: core: bail out if user gives an unknown RefId when using new_id 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 9b29e5c94be7..620a0baf103e 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -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);