Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Valentina Manea and committed by
Greg Kroah-Hartman
87f627f7 6080cd0e

+15 -2
+15 -2
drivers/staging/usbip/userspace/libsrc/usbip_common.c
··· 127 127 goto err; 128 128 } 129 129 130 + /* The client chooses the device configuration 131 + * when attaching it so right after being bound 132 + * to usbip-host on the server the device will 133 + * have no configuration. 134 + * Therefore, attributes such as bConfigurationValue 135 + * and bNumInterfaces will not exist and sscanf will 136 + * fail. Check for these cases and don't treat them 137 + * as errors. 138 + */ 139 + 130 140 ret = sscanf(attr, format, &num); 131 141 if (ret < 1) { 132 - err("sscanf failed"); 133 - goto err; 142 + if (strcmp(name, "bConfigurationValue") && 143 + strcmp(name, "bNumInterfaces")) { 144 + err("sscanf failed for attribute %s", name); 145 + goto err; 146 + } 134 147 } 135 148 136 149 err: