Skip to contentSkip to conversation

tools/usb/usbip reports errors based on uninitialized value

DISCUSSION [email protected] 2 participants 2 messages Aug 19, 2022 USB

lore
Share & tools
lore
#0 lore raw

Consider handling the 'usbip list' command:

Here an uninitialized 'status' variable is declared:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_list
.c#L54

'status' is provided as an output variable here:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_list
.c#L62

However, 'usbip_net_recv_op_common' (defined here:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_netw
ork.c#L162) can fail and return for several reasons before setting 'status'.

The caller uses 'status' (which is still uninitialized) to report an error text here:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_list
.c#L65

This leads to random error messages. Sometimes the accidental value of status maps to a specific error text (which is not informative about the actual error), but most of the times it will lead to "Unknown Op Common Status".

F.

maintainer
#1 lore raw
Quoted 19 lines · On Fri, Aug 19, 2022 at 03:53:36PM +0200, [email protected] wrote:

Consider handling the 'usbip list' command:

Here an uninitialized 'status' variable is declared:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_list
.c#L54

'status' is provided as an output variable here:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_list
.c#L62

However, 'usbip_net_recv_op_common' (defined here:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_netw
ork.c#L162) can fail and return for several reasons before setting 'status'.

The caller uses 'status' (which is still uninitialized) to report an error text here:
https://github.com/torvalds/linux/blob/master/tools/usb/usbip/src/usbip_list
.c#L65

Quoted 4 lines

This leads to random error messages. Sometimes the accidental value of status maps to a specific error text (which is not informative about the actual error), but most of the times it will lead to "Unknown Op Common Status".

Please feel free to submit a series of patches for these issues!

thanks,

greg k-h