Re: [PATCH 1/3] usb: usbtmc: Fix erroneous get_stb ioctl error returns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 26, 2025 at 09:12:20PM +0200, Dave Penkler wrote:
> wait_event_interruptible_timeout returns a long
> The return was being assigned to an int causing an integer overflow when
> the remaining jiffies > INT_MAX resulting in random error returns.
> 
> Use a long return value and convert to int ioctl return only on error.
> 
> On success the ioctl was returning the transfer length of the
> usb_control_msg which has no meaning for the user.
> Return 0 on success.
> 
> Reported-by: Michael Katzmann <vk2bea@xxxxxxxxx>
> Fixes: dbf3e7f654c0 ("Implement an ioctl to support the USMTMC-USB488 READ_STATUS_BYTE operation.")
> Signed-off-by: Dave Penkler <dpenkler@xxxxxxxxx>
> ---
>  drivers/usb/class/usbtmc.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
> index 34e46ef308ab..e24277fef54a 100644
> --- a/drivers/usb/class/usbtmc.c
> +++ b/drivers/usb/class/usbtmc.c
> @@ -482,6 +482,7 @@ static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
>  	u8 *buffer;
>  	u8 tag;
>  	int rv;
> +	long wait_rv;
>  
>  	dev_dbg(dev, "Enter ioctl_read_stb iin_ep_present: %d\n",
>  		data->iin_ep_present);
> @@ -511,16 +512,17 @@ static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
>  	}
>  
>  	if (data->iin_ep_present) {
> -		rv = wait_event_interruptible_timeout(
> +		wait_rv = wait_event_interruptible_timeout(
>  			data->waitq,
>  			atomic_read(&data->iin_data_valid) != 0,
>  			file_data->timeout);
> -		if (rv < 0) {
> -			dev_dbg(dev, "wait interrupted %d\n", rv);
> +		if (wait_rv < 0) {
> +			dev_dbg(dev, "wait interrupted %ld\n", wait_rv);
> +			rv = wait_rv;
>  			goto exit;
>  		}
>  
> -		if (rv == 0) {
> +		if (wait_rv == 0) {
>  			dev_dbg(dev, "wait timed out\n");
>  			rv = -ETIMEDOUT;
>  			goto exit;
> @@ -539,6 +541,8 @@ static int usbtmc_get_stb(struct usbtmc_file_data *file_data, __u8 *stb)
>  
>  	dev_dbg(dev, "stb:0x%02x received %d\n", (unsigned int)*stb, rv);
>  
> +	rv = 0;
> +
>   exit:
>  	/* bump interrupt bTag */
>  	data->iin_bTag += 1;
> -- 
> 2.49.0
> 
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux