linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: Wang Cheng <wanngchenng@gmail.com>, dan.carpenter@oracle.com
Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] staging: rtl8712: add error handler in r8712_usbctrl_vendorreq()
Date: Fri, 6 May 2022 15:13:23 +0300	[thread overview]
Message-ID: <b29ae3f8-c00d-d36d-cdd0-b7a5ccf4cab9@gmail.com> (raw)
In-Reply-To: <e33ea53d36c422fbe7eabec5bd9eecb0ebce1bc5.1651833575.git.wanngchenng@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1677 bytes --]

Hi Wang,

On 5/6/22 15:01, Wang Cheng wrote:
> When 'status' returned from usb_control_msg() is not equal to 'len',
> that usb_control_msg() is on partial failure, r8712_usbctrl_vendorreq()
> will treat partial reads as success.
> 
> Signed-off-by: Wang Cheng <wanngchenng@gmail.com>
> ---
>   drivers/staging/rtl8712/usb_ops_linux.c | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/usb_ops_linux.c b/drivers/staging/rtl8712/usb_ops_linux.c
> index f984a5ab2c6f..b2181e1e2d38 100644
> --- a/drivers/staging/rtl8712/usb_ops_linux.c
> +++ b/drivers/staging/rtl8712/usb_ops_linux.c
> @@ -495,14 +495,21 @@ int r8712_usbctrl_vendorreq(struct intf_priv *pintfpriv, u8 request, u16 value,
>   	}
>   	status = usb_control_msg(udev, pipe, request, reqtype, value, index,
>   				 pIo_buf, len, 500);
> -	if (status > 0) {  /* Success this control transfer. */
> -		if (requesttype == 0x01) {
> -			/* For Control read transfer, we have to copy the read
> -			 * data from pIo_buf to pdata.
> -			 */
> -			memcpy(pdata, pIo_buf,  status);
> -		}
> +	if (status < 0)
> +		goto free;
> +	if (status != len) {
> +		status = -EREMOTEIO;
> +		goto free;
> +	}
> +	/* Success this control transfer. */
> +	if (requesttype == 0x01) {
> +		/* For Control read transfer, we have to copy the read
> +		 * data from pIo_buf to pdata.
> +		 */
> +		memcpy(pdata, pIo_buf, status);
>   	}
> +
> +free:
>   	kfree(palloc_buf);
>   	return status;
>   }

Ah, here it is. This patch should be 1st in the series, since 1/3 now 
looks buggy.




With regards,
Pavel Skripkin

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

      reply	other threads:[~2022-05-06 12:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06 11:59 [PATCH v3 0/3] staging: rtl8712: fix KMSAN: uninit-value in r871xu_drv_init Wang Cheng
2022-05-06 11:59 ` [PATCH v3 1/3] staging: rtl8712: fix uninit-value in usb_read8() and friends Wang Cheng
2022-05-06 12:12   ` Pavel Skripkin
2022-05-10  3:34     ` Wang Cheng
2022-05-06 11:59 ` [PATCH v3 2/3] staging: rtl8712: fix uninit-value in r871xu_drv_init() Wang Cheng
2022-05-06 12:27   ` Pavel Skripkin
2022-05-06 12:35     ` Pavel Skripkin
2022-05-06 12:01 ` [PATCH v3 3/3] staging: rtl8712: add error handler in r8712_usbctrl_vendorreq() Wang Cheng
2022-05-06 12:13   ` Pavel Skripkin [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=b29ae3f8-c00d-d36d-cdd0-b7a5ccf4cab9@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=wanngchenng@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).