mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Serhat Kumral <serhatkumral1@gmail.com>
Cc: israel.a.cepeda.lopez@intel.com, hansg@kernel.org,
	sakari.ailus@linux.intel.com, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: misc: usbio: Handle negative error code from usb_control_msg()
Date: Sat, 3 Oct 2026 17:13:45 +0200	[thread overview]
Message-ID: <2026100327-doornail-jaws-c582@gregkh> (raw)
In-Reply-To: <20261003142838.19019-1-serhatkumral1@gmail.com>

On Sat, Oct 03, 2026 at 05:28:38PM +0300, Serhat Kumral wrote:
> The sizeof(*cpkt) is unsigned, so comparing "ret < sizeof(*cpkt)" promotes
> "ret" to unsigned and negative error codes from usb_control_msg() are
> not caught. Cast the sizeof to int so the error handling works.
> 
> Fixes: 121a0f839dbb ("usb: misc: Add Intel USBIO bridge driver")
> Assisted-by: LLM
> Signed-off-by: Serhat Kumral <serhatkumral1@gmail.com>
> ---
> found by smatch:
> - drivers/usb/misc/usbio.c:187 usbio_ctrl_msg() warn: error code type promoted to positive: 'ret'
> 
>  drivers/usb/misc/usbio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/usbio.c b/drivers/usb/misc/usbio.c
> index fe093e7760d5..3f73f7c3d68a 100644
> --- a/drivers/usb/misc/usbio.c
> +++ b/drivers/usb/misc/usbio.c
> @@ -184,7 +184,7 @@ static int usbio_ctrl_msg(struct usbio_device *usbio, u8 type, u8 cmd,
>  	dev_dbg(usbio->dev, "control in %d hdr %*phN data %*phN\n", ret,
>  		(int)sizeof(*cpkt), cpkt, (int)cpkt->len, cpkt->data);
>  
> -	if (ret < sizeof(*cpkt)) {
> +	if (ret < (int)sizeof(*cpkt)) {

Ick, really?  There's no compiler check for this type of thing?

This whole function needs to be rewritten to use the "modern" control
message functions.  I gave it a go once, but it quickly got messy as
this is an abused function and it really should be massivly cleaned up.

Do you have the hardware for this to test changes?

thanks,

greg k-h

  reply	other threads:[~2026-10-03 15:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03 14:28 Serhat Kumral
2026-10-03 15:13 ` Greg KH [this message]
2026-10-03 16:18   ` Serhat Kumral

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=2026100327-doornail-jaws-c582@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=hansg@kernel.org \
    --cc=israel.a.cepeda.lopez@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=serhatkumral1@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

all inboxes | Powered by JetHome®