mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Collin <davidcollin899@gmail.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Collin <davidcollin899@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH v2 1/2] usb: dwc3: host: fix dangling xhci pointer on init failure
Date: Sat,  5 Sep 2026 12:44:47 -0400	[thread overview]
Message-ID: <20260905164448.209348-1-davidcollin899@gmail.com> (raw)
In-Reply-To: <aptV-QHKGbMqw1uP@vbox>

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


  reply	other threads:[~2026-09-05 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 14:02 [PATCH] usb: dwc3: host: fix props[] overflow and dangling xhci pointer on error David Collin
2026-09-04 23:39 ` Thinh Nguyen
2026-09-05 16:44   ` David Collin [this message]
2026-09-05 16:44     ` [PATCH v2 2/2] usb: dwc3: host: fix props[] overflow when all quirks are enabled David Collin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260905164448.209348-1-davidcollin899@gmail.com \
    --to=davidcollin899@gmail.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®