Skip to contentSkip to conversation

staging: gpib: fix uninitialized variable in usb_gpib_command()

PATCH New Dan Carpenter 1 participant 1 message Oct 17, 2024

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

PATCH 1/1 staging: gpib: fix uninitialized variable in usb_gpib_command()

The number of bytes written is supposed to be zero at the start of this function but only one caller, ibcmd(), initializes it to zero. For the other three callers, setup_serial_poll(), read_serial_poll_byte() and cleanup_serial_poll(), it's an uninitialized variable.

Fixes fce79512a96a ("staging: gpib: Add LPVO DIY USB GPIB driver")
---
 drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/gpib/lpvo_usb_gpib/lpvo_usb_gpib.c +1 -0
index aa7af352e709..4bcbaee65aa9 100644
@@ -596,6 +596,7 @@ static int usb_gpib_command(gpib_board_t *board,
 
 	set_timeout(board);
 
+	*bytes_written = 0;
 	for (i = 0 ; i < length ; i++) {
 		command[3] = buffer[i];
 		retval = send_command(board, command, 5);
Signature · 1 line
2.45.2