usb: storage: freecom: drop useless assignment in init_freecom()
Subsystems (2)
PATCH 1/1 usb: storage: freecom: drop useless assignment in init_freecom()
In init_freecom(), the results of usb_stor_control_msg() calls are stored in the local variable and then printed out by usb_stor_dbg() (if enabled), except for the 1st call, the result of which is completely ignored. Drop the useless assignment.
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo...
drivers/usb/storage/freecom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/freecom.c +1 -1
@@ -446,7 +446,7 @@ static int init_freecom(struct us_data ** all our packets. No need to allocate any extra buffer space. */ - result =usb_stor_control_msg (us, us->recv_ctrl_pipe, +usb_stor_control_msg (us, us->recv_ctrl_pipe,0x4c ,0xc0 ,0x4346 ,0x0 , buffer,0x20 ,3 *HZ ); buffer[32 ] ='\0' ;usb_stor_dbg (us,"String returned from FC init is: %s\n" , buffer);
Greg Kroah-Hartman
maintainerQuoted 4 lines · Sergey Shtylyov
In
init_freecom(), the results ofusb_stor_control_msg()calls are stored in the local variable and then printed out byusb_stor_dbg()(if enabled), except for the 1st call, the result of which is completely ignored. Drop the useless assignment.
Instead, you should check the return value and handle it properly, don't just drop the checking entirely, that's not good.
thanks,
greg k-h
On 12/4/23 10:04 AM, Greg Kroah-Hartman wrote:
[...]
Quoted 7 lines
Quoted 4 lines
In
init_freecom(), the results ofusb_stor_control_msg()calls are stored in the local variable and then printed out byusb_stor_dbg()(if enabled), except for the 1st call, the result of which is completely ignored. Drop the useless assignment.Instead, you should check the return value and handle it properly, don't just drop the checking entirely, that's not good.
Hmm... I wonder if you'd actually read the patch...
I'm not dropping any checking because there's none, even at the further
call sites of usb_stor_control_msg() -- the most init_freecom() currently is doing is printing out the result of the calls...
Quoted 3 lines
thanks,
greg k-h
MBR, Sergey
On 12/7/23 7:16 PM, Sergey Shtylyov wrote:
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
In
init_freecom(), the results ofusb_stor_control_msg()calls are stored in the local variable and then printed out byusb_stor_dbg()(if enabled), except for the 1st call, the result of which is completely ignored. Drop the useless assignment.
Quoted 7 lines
Quoted 2 lines
Instead, you should check the return value and handle it properly, don't just drop the checking entirely, that's not good.
Hmm... I wonder if you'd actually read the patch...
I'm not dropping any checking because there's none, even at the further
call sites ofusb_stor_control_msg()-- the mostinit_freecom()currently is doing is printing out the result of the calls...
Alan, haven't heard your opinion on this patch... What do you think?
[...]
MBR, Sergey
Quoted 11 lines · Sergey Shtylyov
On 12/7/23 7:16 PM, Sergey Shtylyov wrote:
[...]
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
In
init_freecom(), the results ofusb_stor_control_msg()calls are stored in the local variable and then printed out byusb_stor_dbg()(if enabled), except for the 1st call, the result of which is completely ignored. Drop the useless assignment.Instead, you should check the return value and handle it properly, don't just drop the checking entirely, that's not good.
Quoted 6 lines
Quoted 4 lines
Hmm... I wonder if you'd actually read the patch...
I'm not dropping any checking because there's none, even at the further
call sites ofusb_stor_control_msg()-- the mostinit_freecom()currently is doing is printing out the result of the calls...Alan, haven't heard your opinion on this patch... What do you think?
Oh, sorry about that. There's nothing wrong with the patch. None of the return values in that function are used for anything other than debug log messages. (It's a little surprising that the original author of this driver didn't put any error checking here.)
Greg, feel free to merge the patch.
Alan Stern