USB: trancevibrator: fix control-request direction
Subsystems (2)
PATCH 1/1 USB: trancevibrator: fix control-request direction
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Fix the set-speed request which erroneously used USB_DIR_IN and update the default timeout argument to match (same value).
--- drivers/usb/misc/trancevibrator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/misc/trancevibrator.c +2 -2
@@ -61,9 +61,9 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr,/* Set speed */ retval =usb_control_msg (tv->udev,usb_sndctrlpipe (tv->udev,0 ),0x01 ,/* vendor request: set speed */ -USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_OTHER , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_OTHER , tv->speed,/* speed value */ -0 ,NULL ,0 ,USB_CTRL_GET_TIMEOUT ); +0 ,NULL ,0 ,USB_CTRL_SET_TIMEOUT );if (retval) { tv->speed = old;dev_dbg (&tv->udev->dev,"retval = %d\n" , retval);
Signature · 1 line
2.26.3
Greg Kroah-Hartman
maintainerQuoted 33 lines · Johan Hovold
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Fix the set-speed request which erroneously used
USB_DIR_INand update the default timeout argument to match (same value).Fixes 5638e4d92e77 ("USB: add PlayStation 2 Trance Vibrator driver")Cc [email protected] # 2.6.19Signed-off-by Johan Hovold <[email protected]>--- drivers/usb/misc/trancevibrator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/usb/misc/trancevibrator.c +2
-2@@ -61,9 +61,9 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr,/* Set speed */ retval =usb_control_msg (tv->udev,usb_sndctrlpipe (tv->udev,0 ),0x01 ,/* vendor request: set speed */ -USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_OTHER , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_OTHER , tv->speed,/* speed value */ -0 ,NULL ,0 ,USB_CTRL_GET_TIMEOUT ); +0 ,NULL ,0 ,USB_CTRL_SET_TIMEOUT );if (retval) { tv->speed = old;dev_dbg (&tv->udev->dev,"retval = %d\n" , retval);Signature · 1 line
2.26.3
Thanks for searching the whole tree for these mistakes, nice work!
greg k-h
Quoted 28 lines · Greg Kroah-Hartman
Quoted 27 lines · Johan Hovold
The direction of the pipe argument must match the request-type direction bit or control requests may fail depending on the host-controller-driver implementation.
Fix the set-speed request which erroneously used
USB_DIR_INand update the default timeout argument to match (same value).Fixes 5638e4d92e77 ("USB: add PlayStation 2 Trance Vibrator driver")Cc [email protected] # 2.6.19Signed-off-by Johan Hovold <[email protected]>--- drivers/usb/misc/trancevibrator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/usb/misc/trancevibrator.c +2
-2@@ -61,9 +61,9 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr,/* Set speed */ retval =usb_control_msg (tv->udev,usb_sndctrlpipe (tv->udev,0 ),0x01 ,/* vendor request: set speed */ -USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_OTHER , +USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_OTHER , tv->speed,/* speed value */ -0 ,NULL ,0 ,USB_CTRL_GET_TIMEOUT ); +0 ,NULL ,0 ,USB_CTRL_SET_TIMEOUT );
Quoted 8 lines
Quoted 6 lines
drivers/usb/misc/trancevibrator.c +0
-0if (retval) { tv->speed = old;dev_dbg (&tv->udev->dev,"retval = %d\n" , retval);Signature · 1 line
2.26.3Thanks for searching the whole tree for these mistakes, nice work!
Thanks, but I only did a first quick scan of the more obvious mismatches when the USB_DIR macros was being used.
I found a few more when grepping for harcoded request types but that still won't catch drivers that use defines for the type and other even harder to detect variants.
Syzbot already found a couple more but it usually doesn't check anything beyond the probe function.
Johan