Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure
       [not found] <aptV-QHKGbMqw1uP@vbox>
@ 2026-09-05 16:44 ` David Collin
  2026-09-05 16:44   ` [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled David Collin
  2026-09-11 23:12   ` [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure Thinh Nguyen
  0 siblings, 2 replies; 4+ messages in thread
From: David Collin @ 2026-09-05 16:44 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, David Collin, stable

dwc3_host_init()'s error path frees xhci via platform_device_put()
but never clears dwc->xhci, leaving a dangling pointer that
dwc3_host_exit() dereferences unconditionally on removal/shutdown.
Clear dwc->xhci on the error path and return early from
dwc3_host_exit() if NULL.

Fixes: d07e8819a03d ("usb: dwc3: add xHCI Host support")
Cc: stable@vger.kernel.org
Signed-off-by: David Collin <davidcollin899@gmail.com>
---
 drivers/usb/dwc3/host.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index c5674161b2b0..74117cbb2f42 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -219,12 +219,16 @@ int dwc3_host_init(struct dwc3 *dwc)
 	return 0;
 err:
 	platform_device_put(xhci);
+	dwc->xhci = NULL;
 	return ret;
 }
 EXPORT_SYMBOL_GPL(dwc3_host_init);
 
 void dwc3_host_exit(struct dwc3 *dwc)
 {
+	if (!dwc->xhci)
+		return;
+
 	if (dwc->sys_wakeup)
 		device_init_wakeup(&dwc->xhci->dev, false);
 
-- 
2.55.0


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

* [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled
  2026-09-05 16:44 ` [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure David Collin
@ 2026-09-05 16:44   ` David Collin
  2026-09-11 23:12     ` Thinh Nguyen
  2026-09-11 23:12   ` [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure Thinh Nguyen
  1 sibling, 1 reply; 4+ messages in thread
From: David Collin @ 2026-09-05 16:44 UTC (permalink / raw)
  To: Thinh Nguyen, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, David Collin, stable

props[] is sized for exactly the number of properties
dwc3_host_init() can populate, leaving no slot for the NULL
terminator property_entries_dup() requires when usb3_lpm_capable,
usb2_lpm_disable, and the <=3.00a PED quirk are all true. Size
props[] for one more slot.

Fixes: 8da7644493b4 ("usb: dwc3: Specify maximum number of XHCI interrupters")
Cc: stable@vger.kernel.org
Signed-off-by: David Collin <davidcollin899@gmail.com>
---
 drivers/usb/dwc3/host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index 74117cbb2f42..cd1e5204ac3a 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -130,7 +130,7 @@ static int dwc3_host_get_irq(struct dwc3 *dwc)
 
 int dwc3_host_init(struct dwc3 *dwc)
 {
-	struct property_entry	props[6];
+	struct property_entry	props[7];
 	struct platform_device	*xhci;
 	int			ret, irq;
 	int			prop_idx = 0;
-- 
2.55.0


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

* Re: [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure
  2026-09-05 16:44 ` [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure David Collin
  2026-09-05 16:44   ` [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled David Collin
@ 2026-09-11 23:12   ` Thinh Nguyen
  1 sibling, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2026-09-11 23:12 UTC (permalink / raw)
  To: David Collin
  Cc: Thinh Nguyen, Greg Kroah-Hartman, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org

On Sat, Sep 05, 2026, David Collin wrote:
> dwc3_host_init()'s error path frees xhci via platform_device_put()
> but never clears dwc->xhci, leaving a dangling pointer that
> dwc3_host_exit() dereferences unconditionally on removal/shutdown.
> Clear dwc->xhci on the error path and return early from
> dwc3_host_exit() if NULL.
> 
> Fixes: d07e8819a03d ("usb: dwc3: add xHCI Host support")
> Cc: stable@vger.kernel.org
> Signed-off-by: David Collin <davidcollin899@gmail.com>
> ---
>  drivers/usb/dwc3/host.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> index c5674161b2b0..74117cbb2f42 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -219,12 +219,16 @@ int dwc3_host_init(struct dwc3 *dwc)
>  	return 0;
>  err:
>  	platform_device_put(xhci);
> +	dwc->xhci = NULL;
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(dwc3_host_init);
>  
>  void dwc3_host_exit(struct dwc3 *dwc)
>  {
> +	if (!dwc->xhci)
> +		return;
> +
>  	if (dwc->sys_wakeup)
>  		device_init_wakeup(&dwc->xhci->dev, false);
>  
> -- 
> 2.55.0
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

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

* Re: [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled
  2026-09-05 16:44   ` [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled David Collin
@ 2026-09-11 23:12     ` Thinh Nguyen
  0 siblings, 0 replies; 4+ messages in thread
From: Thinh Nguyen @ 2026-09-11 23:12 UTC (permalink / raw)
  To: David Collin
  Cc: Thinh Nguyen, Greg Kroah-Hartman, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org

On Sat, Sep 05, 2026, David Collin wrote:
> props[] is sized for exactly the number of properties
> dwc3_host_init() can populate, leaving no slot for the NULL
> terminator property_entries_dup() requires when usb3_lpm_capable,
> usb2_lpm_disable, and the <=3.00a PED quirk are all true. Size
> props[] for one more slot.
> 
> Fixes: 8da7644493b4 ("usb: dwc3: Specify maximum number of XHCI interrupters")
> Cc: stable@vger.kernel.org
> Signed-off-by: David Collin <davidcollin899@gmail.com>
> ---
>  drivers/usb/dwc3/host.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> index 74117cbb2f42..cd1e5204ac3a 100644
> --- a/drivers/usb/dwc3/host.c
> +++ b/drivers/usb/dwc3/host.c
> @@ -130,7 +130,7 @@ static int dwc3_host_get_irq(struct dwc3 *dwc)
>  
>  int dwc3_host_init(struct dwc3 *dwc)
>  {
> -	struct property_entry	props[6];
> +	struct property_entry	props[7];
>  	struct platform_device	*xhci;
>  	int			ret, irq;
>  	int			prop_idx = 0;
> -- 
> 2.55.0
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>

Thanks,
Thinh

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

end of thread, other threads:[~2026-09-11 23:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <aptV-QHKGbMqw1uP@vbox>
2026-09-05 16:44 ` [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure David Collin
2026-09-05 16:44   ` [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled David Collin
2026-09-11 23:12     ` Thinh Nguyen
2026-09-11 23:12   ` [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure Thinh Nguyen

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