staging: usbip: userspace: don't throw error when trying to read configuration specif...
authorValentina Manea <valentina.manea.m@gmail.com>
Sat, 8 Mar 2014 12:53:35 +0000 (14:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Mar 2014 06:50:24 +0000 (22:50 -0800)
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.

Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/usbip/userspace/libsrc/usbip_common.c

index 998c11c6b32398157ac0072b26b1195e70334708..238bf5bf7f4c6adcbd1b91fe71163055e6f043c0 100644 (file)
@@ -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) {
-               err("sscanf failed");
-               goto err;
+               if (strcmp(name, "bConfigurationValue") &&
+                               strcmp(name, "bNumInterfaces")) {
+                       err("sscanf failed for attribute %s", name);
+                       goto err;
+               }
        }
 
 err: