linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] USB: serial: ir-usb: Silence harmless uninitialized variable warning
@ 2020-01-29 17:30 Dan Carpenter
  2020-01-30 10:12 ` Johan Hovold
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-01-29 17:30 UTC (permalink / raw)
  To: Johan Hovold; +Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors

The "actual_length" variable might be uninitialized on some failure
paths.  It's harmless but static analysis tools like Smatch complain
and at runtime the UBSan tool will likely complain as well.

Fixes: e7542bc382f8 ("USB: serial: ir-usb: make set_termios synchronous")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/serial/ir-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 79d0586e2b33..172261a908d8 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -448,7 +448,7 @@ static void ir_set_termios(struct tty_struct *tty,
 			usb_sndbulkpipe(udev, port->bulk_out_endpointAddress),
 			transfer_buffer, 1, &actual_length, 5000);
 	if (ret || actual_length != 1) {
-		if (actual_length != 1)
+		if (!ret)
 			ret = -EIO;
 		dev_err(&port->dev, "failed to change line speed: %d\n", ret);
 	}
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] USB: serial: ir-usb: Silence harmless uninitialized variable warning
  2020-01-29 17:30 [PATCH] USB: serial: ir-usb: Silence harmless uninitialized variable warning Dan Carpenter
@ 2020-01-30 10:12 ` Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2020-01-30 10:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Johan Hovold, Greg Kroah-Hartman, linux-usb, kernel-janitors

On Wed, Jan 29, 2020 at 08:30:37PM +0300, Dan Carpenter wrote:
> The "actual_length" variable might be uninitialized on some failure
> paths.  It's harmless but static analysis tools like Smatch complain
> and at runtime the UBSan tool will likely complain as well.
> 
> Fixes: e7542bc382f8 ("USB: serial: ir-usb: make set_termios synchronous")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Nice catch, I'll queue this up for 5.6-rc.

> ---
>  drivers/usb/serial/ir-usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
> index 79d0586e2b33..172261a908d8 100644
> --- a/drivers/usb/serial/ir-usb.c
> +++ b/drivers/usb/serial/ir-usb.c
> @@ -448,7 +448,7 @@ static void ir_set_termios(struct tty_struct *tty,
>  			usb_sndbulkpipe(udev, port->bulk_out_endpointAddress),
>  			transfer_buffer, 1, &actual_length, 5000);
>  	if (ret || actual_length != 1) {
> -		if (actual_length != 1)
> +		if (!ret)
>  			ret = -EIO;
>  		dev_err(&port->dev, "failed to change line speed: %d\n", ret);
>  	}

Johan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-30 10:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 17:30 [PATCH] USB: serial: ir-usb: Silence harmless uninitialized variable warning Dan Carpenter
2020-01-30 10:12 ` Johan Hovold

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).