public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: usb-acpi: fix uninitialized variable in usb_acpi_get_connect_type()
@ 2024-03-15 15:21 Dan Carpenter
  2024-03-15 15:36 ` Mathias Nyman
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-03-15 15:21 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Greg Kroah-Hartman, Andy Shevchenko, linux-usb, linux-kernel,
	kernel-janitors

The "pld" pointer is uninitialized if acpi_get_physical_device_location()
fails.  Initialize it to NULL.

Fixes: f3ac348e6e04 ("usb: usb-acpi: Set port connect type of not connectable ports correctly")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/usb/core/usb-acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index f250dfc3b14d..2aeeaa389380 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -153,8 +153,8 @@ usb_acpi_get_connect_type(struct usb_port *port_dev, acpi_handle *handle)
 {
 	enum usb_port_connect_type connect_type = USB_PORT_CONNECT_TYPE_UNKNOWN;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+	struct acpi_pld_info *pld = NULL;
 	union acpi_object *upc = NULL;
-	struct acpi_pld_info *pld;
 	acpi_status status;
 
 	/*
-- 
2.43.0


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

* Re: [PATCH] usb: usb-acpi: fix uninitialized variable in usb_acpi_get_connect_type()
  2024-03-15 15:21 [PATCH] usb: usb-acpi: fix uninitialized variable in usb_acpi_get_connect_type() Dan Carpenter
@ 2024-03-15 15:36 ` Mathias Nyman
  2024-03-15 18:43   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Mathias Nyman @ 2024-03-15 15:36 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, Andy Shevchenko, linux-usb, linux-kernel,
	kernel-janitors

On 15.3.2024 17.21, Dan Carpenter wrote:
> The "pld" pointer is uninitialized if acpi_get_physical_device_location()
> fails.  Initialize it to NULL.
> 
> Fixes: f3ac348e6e04 ("usb: usb-acpi: Set port connect type of not connectable ports correctly")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---

I sent a similar patch a week ago, just before merge window opened.
looks like it didn't make it.

https://lore.kernel.org/linux-usb/20240308113425.1144689-1-mathias.nyman@linux.intel.com/

Thanks
Mathias


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

* Re: [PATCH] usb: usb-acpi: fix uninitialized variable in usb_acpi_get_connect_type()
  2024-03-15 15:36 ` Mathias Nyman
@ 2024-03-15 18:43   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-03-15 18:43 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: Greg Kroah-Hartman, Andy Shevchenko, linux-usb, linux-kernel,
	kernel-janitors

On Fri, Mar 15, 2024 at 05:36:16PM +0200, Mathias Nyman wrote:
> On 15.3.2024 17.21, Dan Carpenter wrote:
> > The "pld" pointer is uninitialized if acpi_get_physical_device_location()
> > fails.  Initialize it to NULL.
> > 
> > Fixes: f3ac348e6e04 ("usb: usb-acpi: Set port connect type of not connectable ports correctly")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> 
> I sent a similar patch a week ago, just before merge window opened.
> looks like it didn't make it.
> 
> https://lore.kernel.org/linux-usb/20240308113425.1144689-1-mathias.nyman@linux.intel.com/

Huh.  That's interesting that this bug was causing issues in real life.
I thought everyone was using the GCC extension to zero stack variables.
I've only been fixing uninitialized variable bugs out of sense of
stubbornness and to boost my patch count.  :P

regards,
dan carpenter


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

end of thread, other threads:[~2024-03-15 18:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-15 15:21 [PATCH] usb: usb-acpi: fix uninitialized variable in usb_acpi_get_connect_type() Dan Carpenter
2024-03-15 15:36 ` Mathias Nyman
2024-03-15 18:43   ` Dan Carpenter

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