public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] USB: trancevibrator: fix control-request direction
Date: Mon, 24 May 2021 13:20:05 +0200	[thread overview]
Message-ID: <YKuL5TcWGiEqofF2@hovoldconsulting.com> (raw)
In-Reply-To: <YKf28CaRalCTsXfO@kroah.com>

On Fri, May 21, 2021 at 08:07:44PM +0200, Greg Kroah-Hartman wrote:
> On Fri, May 21, 2021 at 03:31:09PM +0200, Johan Hovold wrote:
> > 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).
> > 
> > Fixes: 5638e4d92e77 ("USB: add PlayStation 2 Trance Vibrator driver")
> > Cc: stable@vger.kernel.org      # 2.6.19
> > Signed-off-by: Johan Hovold <johan@kernel.org>
> > ---
> >  drivers/usb/misc/trancevibrator.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
> > index a3dfc77578ea..26baba3ab7d7 100644
> > --- a/drivers/usb/misc/trancevibrator.c
> > +++ b/drivers/usb/misc/trancevibrator.c
> > @@ -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);
> > -- 
> > 2.26.3
> > 
> 
> Thanks 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

      reply	other threads:[~2021-05-24 11:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21 13:31 [PATCH] USB: trancevibrator: fix control-request direction Johan Hovold
2021-05-21 18:07 ` Greg Kroah-Hartman
2021-05-24 11:20   ` Johan Hovold [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YKuL5TcWGiEqofF2@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox