diff mbox series

usb: dwc3: fix possible object reference leak

Message ID tencent_6BA8EA125537CBB5D65B05605E1E960AA708@qq.com (mailing list archive)
State New, archived
Headers show
Series usb: dwc3: fix possible object reference leak | expand

Commit Message

Zhang Shurong Oct. 5, 2023, 1:49 p.m. UTC
The of_find_device_by_node takes a reference to the struct device
when find the match device,we should release it when fail.

Fix it by calling by calling platform_device_put when error returns.

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/usb/dwc3/dwc3-imx8mp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Zhang Shurong Oct. 5, 2023, 3:01 p.m. UTC | #1
I apologize for the poorly formatted patch.
I will make the necessary revisions and send it to you again.
Additionally, I thought that it may not be straightforward
to test but I will try.

Kind regards,
Shurong

在 2023/10/5 21:59, Greg KH 写道:
> On Thu, Oct 05, 2023 at 09:49:46PM +0800, Zhang Shurong wrote:
>> The of_find_device_by_node takes a reference to the struct device
>> when find the match device,we should release it when fail.
>>
>> Fix it by calling by calling platform_device_put when error returns.
>>
>> Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
>> ---
> What commit id does this fix?
>
> And how did you find this?  How was it tested?
>
> thanks,
>
> greg k-h
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-imx8mp.c b/drivers/usb/dwc3/dwc3-imx8mp.c
index a1e15f2fffdb..af5302c3f7a9 100644
--- a/drivers/usb/dwc3/dwc3-imx8mp.c
+++ b/drivers/usb/dwc3/dwc3-imx8mp.c
@@ -244,7 +244,7 @@  static int dwc3_imx8mp_probe(struct platform_device *pdev)
 					IRQF_ONESHOT, dev_name(dev), dwc3_imx);
 	if (err) {
 		dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err);
-		goto depopulate;
+		goto err_device_put;
 	}
 
 	device_set_wakeup_capable(dev, true);
@@ -252,6 +252,8 @@  static int dwc3_imx8mp_probe(struct platform_device *pdev)
 
 	return 0;
 
+err_device_put:
+	platform_device_put(dwc3_imx->dwc3);
 depopulate:
 	of_platform_depopulate(dev);
 err_node_put: