Skip to contentSkip to conversation

USB: serial: ir-usb: Silence harmless uninitialized variable warning

PATCH In review Dan Carpenter 2 participants 2 messages Jan 29, 2020 – Jan 30, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: serial: ir-usb: Silence harmless uninitialized variable warning

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")
---
 drivers/usb/serial/ir-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/ir-usb.c +1 -1
index 79d0586e2b33..172261a908d8 100644
@@ -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);
 	}
Signature · 1 line
2.11.0
maintainer
#1 lore raw
Quoted 6 lines · Dan Carpenter

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

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

Quoted 9 lines
---
 drivers/usb/serial/ir-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/serial/ir-usb.c +0 -0
index 79d0586e2b33..172261a908d8 100644

drivers/usb/serial/ir-usb.c static void ir_set_termios(struct tty_struct *tty, · line 454

Quoted 8 lines
drivers/usb/serial/ir-usb.c +1 -1
@@ -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