Message ID | tencent_6BA8EA125537CBB5D65B05605E1E960AA708@qq.com |
---|---|
State | New |
Headers | show |
Series | usb: dwc3: fix possible object reference leak | expand |
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 --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:
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(-)