* [PATCH] xhci: Fix bcdUSB initialization
@ 2025-02-27 19:34 Abhishek Tamboli
2025-02-27 19:36 ` Greg KH
2025-02-27 20:15 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Abhishek Tamboli @ 2025-02-27 19:34 UTC (permalink / raw)
To: mathias.nyman, gregkh; +Cc: linux-usb, linux-kernel, dan.carpenter
Initialize bcdUSB to 0 to prevent undefined behaviour
if accessed without being explicitly set.
Fix the following smatch error:
drivers/usb/host/xhci-hub.c:71 xhci_create_usb3x_bos_desc()
error: uninitialized symbol 'bcdUSB'
Signed-off-by: Abhishek Tamboli <abhishektamboli9@gmail.com>
---
drivers/usb/host/xhci-hub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 9693464c0520..5715a8bdda7f 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xhci: Fix bcdUSB initialization
2025-02-27 19:34 [PATCH] xhci: Fix bcdUSB initialization Abhishek Tamboli
@ 2025-02-27 19:36 ` Greg KH
2025-02-27 20:11 ` Abhishek Tamboli
2025-02-27 20:16 ` Dan Carpenter
2025-02-27 20:15 ` Dan Carpenter
1 sibling, 2 replies; 5+ messages in thread
From: Greg KH @ 2025-02-27 19:36 UTC (permalink / raw)
To: Abhishek Tamboli; +Cc: mathias.nyman, linux-usb, linux-kernel, dan.carpenter
On Fri, Feb 28, 2025 at 01:04:00AM +0530, Abhishek Tamboli wrote:
> Initialize bcdUSB to 0 to prevent undefined behaviour
> if accessed without being explicitly set.
Is it actually accessed without being set? If so, please explain it and
also how the compiler is somehow missing this already?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xhci: Fix bcdUSB initialization
2025-02-27 19:36 ` Greg KH
@ 2025-02-27 20:11 ` Abhishek Tamboli
2025-02-27 20:16 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Abhishek Tamboli @ 2025-02-27 20:11 UTC (permalink / raw)
To: Greg KH; +Cc: mathias.nyman, linux-usb, linux-kernel, dan.carpenter
Hi Greg,
Thanks for the review.
> On Fri, Feb 28, 2025 at 01:04:00AM +0530, Abhishek Tamboli wrote:
> > Initialize bcdUSB to 0 to prevent undefined behaviour
> > if accessed without being explicitly set.
>
> Is it actually accessed without being set? If so, please explain it and
> also how the compiler is somehow missing this already?
I added bcdUSB = 0 based on a Smatch warning about potential uninitialized access.
However, given that bcdUSB is always set in the first loop iteration,
this might be a false positive.
Regards,
Abhishek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xhci: Fix bcdUSB initialization
2025-02-27 19:34 [PATCH] xhci: Fix bcdUSB initialization Abhishek Tamboli
2025-02-27 19:36 ` Greg KH
@ 2025-02-27 20:15 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-02-27 20:15 UTC (permalink / raw)
To: Abhishek Tamboli; +Cc: mathias.nyman, gregkh, linux-usb, linux-kernel
On Fri, Feb 28, 2025 at 01:04:00AM +0530, Abhishek Tamboli wrote:
> Initialize bcdUSB to 0 to prevent undefined behaviour
> if accessed without being explicitly set.
>
> Fix the following smatch error:
> drivers/usb/host/xhci-hub.c:71 xhci_create_usb3x_bos_desc()
> error: uninitialized symbol 'bcdUSB'
>
> Signed-off-by: Abhishek Tamboli <abhishektamboli9@gmail.com>
> ---
The concern here would be that xhci->num_port_caps is <= 0. That's
probably not possible so it's likely a false positive.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xhci: Fix bcdUSB initialization
2025-02-27 19:36 ` Greg KH
2025-02-27 20:11 ` Abhishek Tamboli
@ 2025-02-27 20:16 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-02-27 20:16 UTC (permalink / raw)
To: Greg KH; +Cc: Abhishek Tamboli, mathias.nyman, linux-usb, linux-kernel
On Thu, Feb 27, 2025 at 11:36:24AM -0800, Greg KH wrote:
> On Fri, Feb 28, 2025 at 01:04:00AM +0530, Abhishek Tamboli wrote:
> > Initialize bcdUSB to 0 to prevent undefined behaviour
> > if accessed without being explicitly set.
>
> Is it actually accessed without being set? If so, please explain it and
> also how the compiler is somehow missing this already?
>
This is a Smatch warning, not a compiler warning.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-02-27 20:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 19:34 [PATCH] xhci: Fix bcdUSB initialization Abhishek Tamboli
2025-02-27 19:36 ` Greg KH
2025-02-27 20:11 ` Abhishek Tamboli
2025-02-27 20:16 ` Dan Carpenter
2025-02-27 20:15 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox