Skip to contentSkip to conversation

staging: usbip: userspace: don't throw error when trying to read configuration specific attributes

PATCH New Valentina Manea 1 participant 1 message Mar 4, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: usbip: userspace: don't throw error when trying to read configuration specific attributes

When a device has just been bound to usbip-host but the client hasn't set a configuration on it, certain attributes will not exist. Don't treat this as an error.

---
 drivers/staging/usbip/userspace/libsrc/usbip_common.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/staging/usbip/userspace/libsrc/usbip_common.c +15 -2
index 8d675a9..ac32a36 100644
@@ -127,10 +127,23 @@ int read_attr_value(struct udev_device *dev, const char *name,
 		goto err;
 	}
 
+	/* The client chooses the device configuration
+	 * when attaching it so right after being bound
+	 * to usbip-host on the server the device will
+	 * have no configuration.
+	 * Therefore, attributes such as bConfigurationValue
+	 * and bNumInterfaces will not exist and sscanf will
+	 * fail. Check for these cases and don't treat them
+	 * as errors.
+	 */
+
 	ret = sscanf(attr, format, &num);
 	if (ret < 1) {
-		dbg("sscanf failed");
-		goto err;
+		if (strcmp(name, "bConfigurationValue") &&
+				strcmp(name, "bNumInterfaces")) {
+			dbg("sscanf failed");
+			goto err;
+		}
 	}
 
 err:
Signature · 1 line
1.8.1.2