usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc()
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/2 usb: xhci: Fix unassigned variable 'tmp_minor_revision' in xhci_add_in_port()
Fix the following smatch error:drivers/usb/host/xhci-mem.c:2060 xhci_add_in_port() error: unassigned variable 'tmp_minor_revision'
--- drivers/usb/host/xhci-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-mem.c +1 -1
@@ -1980,7 +1980,7 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports, {u32 temp, port_offset, port_count;int i; -u8 major_revision, minor_revision, tmp_minor_revision; +u8 major_revision, minor_revision, tmp_minor_revision =0 ;struct xhci_hub *rhub;struct device *dev =xhci_to_hcd (xhci)->self.sysdev;struct xhci_port_cap *port_cap;
Signature · 1 line
2.17.1
PATCH v2 2/2 usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc()
In reply to a message not in the archiveFix the following smatch error:drivers/usb/host/xhci-hub.c:71 xhci_create_usb3x_bos_desc() error: unassigned variable 'bcdUSB'
--- drivers/usb/host/xhci-hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-hub.c +1 -1
@@ -39,7 +39,7 @@ static int xhci_create_usb3x_bos_desc(struct xhci_hcd *xhci, char *buf,struct usb_ss_cap_descriptor *ss_cap;struct usb_ssp_cap_descriptor *ssp_cap;struct xhci_port_cap *port_cap =NULL ; -u16 bcdUSB; +u16 bcdUSB =0 ;u32 reg;u32 min_rate =0 ;u8 min_ssid;
Signature · 1 line
2.17.1
Greg KH
maintainerQuoted 2 lines · Selvarasu Ganesan
Fix the following smatch error:
drivers/usb/host/xhci-hub.c:71xhci_create_usb3x_bos_desc()error: unassigned variable 'bcdUSB'
That really doesn't say what is happening here at all. Please provide a lot more information as the response from a tool could, or could not, be a real issue, how are we supposed to know?
And "unassigned" really isn't the bug that is being fixed here, please describe it better.
Same for patch 2 of the series.
Also, your 0/2 email was not threaded with these patches, something odd happened in your email setup, you might want to look into that.
thanks,
greg k-h
Quoted 10 lines · Greg KH
Quoted 2 lines · Selvarasu Ganesan
Fix the following smatch error:
drivers/usb/host/xhci-hub.c:71xhci_create_usb3x_bos_desc()error: unassigned variable 'bcdUSB'That really doesn't say what is happening here at all. Please provide a lot more information as the response from a tool could, or could not, be a real issue, how are we supposed to know?
And "unassigned" really isn't the bug that is being fixed here, please describe it better.
Quoted 9 lines
Same for patch 2 of the series.
Also, your 0/2 email was not threaded with these patches, something odd happened in your email setup, you might want to look into that.
thanks,
greg k-h
Hi Greg,
I understand your concern about whether the response from the tool could be a real issue or not. However, please check the provided code, I believe there is an issue worth considering.
In both conditions of the code snippet, the logical check is not valid because the 'bcdUSB' variable has not been assigned any value initially. Therefore, we believe that the tool is correctly identifying this problem.
If you do not consider it an issue, we can ignore this commit.
Please find the relevant portion of the code below:
========================================================================
u16 bcdUSB;
...
...
/* Create the descriptor for port with the highest revision */ for (i = 0; i < xhci->num_port_caps; i++) {
..
..
* if (i == 0 || bcdUSB < rev) { *
bcdUSB = rev;
port_cap = &xhci->port_caps[i];
}
}
..
..
*if (bcdUSB >= 0x0310) {* //*Logically invalid to check bcdUSB without assigning a valuewhere above **xhci->num_port_caps become NULL*.
if (port_cap->psi_count) {
u8 num_sym_ssa = 0;
=======================================================================
yeah some issue in ouremail setup. We will fix it.
Greg KH
maintainerQuoted 19 lines · Selvarasu Ganesan
Quoted 17 lines · Greg KH
Quoted 2 lines · Selvarasu Ganesan
Fix the following smatch error:
drivers/usb/host/xhci-hub.c:71xhci_create_usb3x_bos_desc()error: unassigned variable 'bcdUSB'That really doesn't say what is happening here at all. Please provide a lot more information as the response from a tool could, or could not, be a real issue, how are we supposed to know?
And "unassigned" really isn't the bug that is being fixed here, please describe it better.
Same for patch 2 of the series.
Also, your 0/2 email was not threaded with these patches, something odd happened in your email setup, you might want to look into that.
thanks,
Quoted 8 lines
Quoted 2 lines
greg k-h
Hi Greg,
I understand your concern about whether the response from the tool could be a real issue or not. However, please check the provided code, I believe there is an issue worth considering.
I am not disagreeing that this is a real issue that should be fixed (but confused as to why the normal compilers are not catching this, which implies that maybe it never can actually be hit).
So please fix up your changelog text and I will be glad to review it.
thanks,
greg k-h