Commit 0cc5e2e7 authored by Oliver Neukum's avatar Oliver Neukum Committed by Greg Kroah-Hartman

USB: fix error handling in trancevibrator

trancevibrator should not pretend success if it returns an error.
Signed-off-by: default avatarOliver Neukum <oneukum@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent efa66f14
...@@ -59,13 +59,14 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr, ...@@ -59,13 +59,14 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
{ {
struct usb_interface *intf = to_usb_interface(dev); struct usb_interface *intf = to_usb_interface(dev);
struct trancevibrator *tv = usb_get_intfdata(intf); struct trancevibrator *tv = usb_get_intfdata(intf);
int temp, retval; int temp, retval, old;
temp = simple_strtoul(buf, NULL, 10); temp = simple_strtoul(buf, NULL, 10);
if (temp > 255) if (temp > 255)
temp = 255; temp = 255;
else if (temp < 0) else if (temp < 0)
temp = 0; temp = 0;
old = tv->speed;
tv->speed = temp; tv->speed = temp;
dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed); dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed);
...@@ -77,6 +78,7 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr, ...@@ -77,6 +78,7 @@ static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
tv->speed, /* speed value */ tv->speed, /* speed value */
0, NULL, 0, USB_CTRL_GET_TIMEOUT); 0, NULL, 0, USB_CTRL_GET_TIMEOUT);
if (retval) { if (retval) {
tv->speed = old;
dev_dbg(&tv->udev->dev, "retval = %d\n", retval); dev_dbg(&tv->udev->dev, "retval = %d\n", retval);
return retval; return retval;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment