driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
From: Quentin Deslandes <quentin.deslandes@itdev.co.uk>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Malcolm Priestley <tvboxspy@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>
Subject: Re: [PATCH 1/5] staging: vt6656: Fix non zero logical return of, usb_control_msg
Date: Mon, 6 Jan 2020 21:45:20 +0000	[thread overview]
Message-ID: <20200106214518.GB54084@jiffies> (raw)
In-Reply-To: <20200103105734.GD3911@kadam>

On 01/03/20 13:58:08, Dan Carpenter wrote:
> On Fri, Dec 20, 2019 at 09:14:59PM +0000, Malcolm Priestley wrote:
> > Starting with commit 59608cb1de1856
> > ("staging: vt6656: clean function's error path in usbpipe.c")
> > the usb control functions have returned errors throughout driver
> > with only logical variable checking.
> 
> Use the Fixes tag for this.
> 
> Fixes: 59608cb1de18 ("staging: vt6656: clean function's error path in usbpipe.c")
> 
> 12 digits to the hash.  Add Quentin to the CC list.
> 
> > 
> > However, usb_control_msg return the amount of bytes transferred
> > this means that normal operation causes errors.
> > 
> > Correct the return function so only return zero when transfer
> > is successful.
> > 
> > Cc: stable <stable@vger.kernel.org> # v5.3+
> > Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
> > ---
> >  drivers/staging/vt6656/usbpipe.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> > index d3304df6bd53..488ebd98773d 100644
> > --- a/drivers/staging/vt6656/usbpipe.c
> > +++ b/drivers/staging/vt6656/usbpipe.c
> > @@ -59,7 +59,9 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
> >  
> >  	kfree(usb_buffer);
> >  
> > -	if (ret >= 0 && ret < (int)length)
> > +	if (ret == (int)length)
> 
> No need for this cast (no need in the original either).
> 
> > +		ret = 0;
> > +	else
> >  		ret = -EIO;
> 
> It would be better to preserve the error codes from usb_control_msg().
> 
> 	if (ret == length)
> 		ret = 0;
> 	else if (ret >= 0)
> 		ret = -EIO;
> 
> regards,
> dan carpenter
> 

Thanks for CC.

Nice catch. Dan is right, we should forward any error code from
usb_control_msg().

Regards,
Quentin Deslandes
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  reply	other threads:[~2020-01-06 22:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-20 21:14 [PATCH 1/5] staging: vt6656: Fix non zero logical return of, usb_control_msg Malcolm Priestley
2020-01-03 10:58 ` Dan Carpenter
2020-01-06 21:45   ` Quentin Deslandes [this message]
2020-01-08 21:55     ` Malcolm Priestley

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=20200106214518.GB54084@jiffies \
    --to=quentin.deslandes@itdev.co.uk \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=tvboxspy@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).