public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] usb: xhci: Fix unassigned variable 'tmp_minor_revision' in xhci_add_in_port()
       [not found] ` <20250213042130.858-1-selvarasu.g@samsung.com>
@ 2025-02-13  4:21   ` Selvarasu Ganesan
  2025-02-13  4:21   ` [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc() Selvarasu Ganesan
  1 sibling, 0 replies; 5+ messages in thread
From: Selvarasu Ganesan @ 2025-02-13  4:21 UTC (permalink / raw)
  To: mathias.nyman, gregkh, WeitaoWang-oc, Thinh.Nguyen, linux-usb,
	linux-kernel
  Cc: jh0801.jung, dh10.jung, naushad, akash.m5, h10.kim, eomji.oh,
	alim.akhtar, thiagu.r, muhammed.ali, pritam.sutar, cpgs,
	Selvarasu Ganesan, stable

Fix the following smatch error:
drivers/usb/host/xhci-mem.c:2060 xhci_add_in_port() error: unassigned variable 'tmp_minor_revision'

Fixes: d9b0328d0b8b ("xhci: Show ZHAOXIN xHCI root hub speed correctly")
Cc: stable@vger.kernel.org
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
---
 drivers/usb/host/xhci-mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 92703efda1f7..8665893df894 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -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;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc()
       [not found] ` <20250213042130.858-1-selvarasu.g@samsung.com>
  2025-02-13  4:21   ` [PATCH v2 1/2] usb: xhci: Fix unassigned variable 'tmp_minor_revision' in xhci_add_in_port() Selvarasu Ganesan
@ 2025-02-13  4:21   ` Selvarasu Ganesan
  2025-02-14  8:05     ` Greg KH
  1 sibling, 1 reply; 5+ messages in thread
From: Selvarasu Ganesan @ 2025-02-13  4:21 UTC (permalink / raw)
  To: mathias.nyman, gregkh, WeitaoWang-oc, Thinh.Nguyen, linux-usb,
	linux-kernel
  Cc: jh0801.jung, dh10.jung, naushad, akash.m5, h10.kim, eomji.oh,
	alim.akhtar, thiagu.r, muhammed.ali, pritam.sutar, cpgs,
	Selvarasu Ganesan, stable

Fix the following smatch error:
drivers/usb/host/xhci-hub.c:71 xhci_create_usb3x_bos_desc() error: unassigned variable 'bcdUSB'

Fixes: eb02aaf21f29 ("usb: xhci: Rewrite xhci_create_usb3_bos_desc()")
Cc: stable@vger.kernel.org
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.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.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc()
  2025-02-13  4:21   ` [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc() Selvarasu Ganesan
@ 2025-02-14  8:05     ` Greg KH
  2025-02-17  6:49       ` Selvarasu Ganesan
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2025-02-14  8:05 UTC (permalink / raw)
  To: Selvarasu Ganesan
  Cc: mathias.nyman, WeitaoWang-oc, Thinh.Nguyen, linux-usb,
	linux-kernel, jh0801.jung, dh10.jung, naushad, akash.m5, h10.kim,
	eomji.oh, alim.akhtar, thiagu.r, muhammed.ali, pritam.sutar, cpgs,
	stable

On Thu, Feb 13, 2025 at 09:51:26AM +0530, Selvarasu Ganesan wrote:
> Fix the following smatch error:
> drivers/usb/host/xhci-hub.c:71 xhci_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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc()
  2025-02-14  8:05     ` Greg KH
@ 2025-02-17  6:49       ` Selvarasu Ganesan
  2025-02-17  7:17         ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Selvarasu Ganesan @ 2025-02-17  6:49 UTC (permalink / raw)
  To: Greg KH
  Cc: mathias.nyman, WeitaoWang-oc, Thinh.Nguyen, linux-usb,
	linux-kernel, jh0801.jung, dh10.jung, naushad, akash.m5, h10.kim,
	eomji.oh, alim.akhtar, thiagu.r, muhammed.ali, pritam.sutar, cpgs,
	stable


On 2/14/2025 1:35 PM, Greg KH wrote:
> On Thu, Feb 13, 2025 at 09:51:26AM +0530, Selvarasu Ganesan wrote:
>> Fix the following smatch error:
>> drivers/usb/host/xhci-hub.c:71 xhci_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
>

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc()
  2025-02-17  6:49       ` Selvarasu Ganesan
@ 2025-02-17  7:17         ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2025-02-17  7:17 UTC (permalink / raw)
  To: Selvarasu Ganesan
  Cc: mathias.nyman, WeitaoWang-oc, Thinh.Nguyen, linux-usb,
	linux-kernel, jh0801.jung, dh10.jung, naushad, akash.m5, h10.kim,
	eomji.oh, alim.akhtar, thiagu.r, muhammed.ali, pritam.sutar, cpgs,
	stable

On Mon, Feb 17, 2025 at 12:19:51PM +0530, Selvarasu Ganesan wrote:
> 
> On 2/14/2025 1:35 PM, Greg KH wrote:
> > On Thu, Feb 13, 2025 at 09:51:26AM +0530, Selvarasu Ganesan wrote:
> >> Fix the following smatch error:
> >> drivers/usb/host/xhci-hub.c:71 xhci_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
> >
> 
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-17  7:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250213042229epcas5p1a3080b21423a43f2e71ab7f631604b1d@epcas5p1.samsung.com>
     [not found] ` <20250213042130.858-1-selvarasu.g@samsung.com>
2025-02-13  4:21   ` [PATCH v2 1/2] usb: xhci: Fix unassigned variable 'tmp_minor_revision' in xhci_add_in_port() Selvarasu Ganesan
2025-02-13  4:21   ` [PATCH v2 2/2] usb: xhci: Fix unassigned variable 'bcdUSB' in xhci_create_usb3x_bos_desc() Selvarasu Ganesan
2025-02-14  8:05     ` Greg KH
2025-02-17  6:49       ` Selvarasu Ganesan
2025-02-17  7:17         ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox