linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 1/3] usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement
@ 2021-02-12 20:55 Serge Semin
  2021-02-12 20:55 ` [PATCH v7 2/3] usb: dwc3: qcom: Detect DWC3 DT-nodes using compatible string Serge Semin
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Serge Semin @ 2021-02-12 20:55 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Rob Herring, Andy Gross,
	Bjorn Andersson, Manu Gautam
  Cc: Serge Semin, Serge Semin, devicetree, linux-usb, Felipe Balbi,
	linux-arm-msm, linux-kernel

of_get_child_by_name() increments the reference counter of the OF node it
managed to find. So after the code is done using the device node, the
refcount must be decremented. Add missing of_node_put() invocation then
to the dwc3_qcom_of_register_core() method, since DWC3 OF node is being
used only there.

Fixes: a4333c3a6ba9 ("usb: dwc3: Add Qualcomm DWC3 glue driver")
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>

---

Note the patch will get cleanly applied on the commit 2bc02355f8ba ("usb:
dwc3: qcom: Add support for booting with ACPI"), while the bug has been
there since the Qualcomm DWC3 glue driver was submitted.

Changelog v7:
- This is a new patch. Please drop it If I missed something and the OF
  node refcount decrement wasn't supposed to be there.
---
 drivers/usb/dwc3/dwc3-qcom.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index c703d552bbcf..3564d00cdce3 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -639,16 +639,19 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev)
 	ret = of_platform_populate(np, NULL, NULL, dev);
 	if (ret) {
 		dev_err(dev, "failed to register dwc3 core - %d\n", ret);
-		return ret;
+		goto node_put;
 	}
 
 	qcom->dwc3 = of_find_device_by_node(dwc3_np);
 	if (!qcom->dwc3) {
+		ret = -ENODEV;
 		dev_err(dev, "failed to get dwc3 platform device\n");
-		return -ENODEV;
 	}
 
-	return 0;
+node_put:
+	of_node_put(dwc3_np);
+
+	return ret;
 }
 
 static int dwc3_qcom_probe(struct platform_device *pdev)
-- 
2.30.0


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

end of thread, other threads:[~2021-03-26 19:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-12 20:55 [PATCH v7 1/3] usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement Serge Semin
2021-02-12 20:55 ` [PATCH v7 2/3] usb: dwc3: qcom: Detect DWC3 DT-nodes using compatible string Serge Semin
2021-02-12 20:55 ` [PATCH v7 3/3] arm64: dts: qcom: Harmonize DWC USB3 DT nodes name Serge Semin
2021-02-18 15:29 ` [PATCH v7 1/3] usb: dwc3: qcom: Add missing DWC3 OF node refcount decrement Serge Semin
2021-02-18 15:32   ` Greg Kroah-Hartman
2021-02-18 15:40     ` Serge Semin
2021-03-23 11:29       ` Greg Kroah-Hartman
2021-03-24 12:18         ` Serge Semin
2021-03-26 13:34           ` Greg Kroah-Hartman
2021-03-26 19:55             ` Serge Semin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).