[PATCH] usb: core: bail out if user gives an unknown RefId when using new_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
---
 drivers/usb/core/driver.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 6dbed5e..024dbfd 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);
-- 
1.8.5.1

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




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux