Skip to content

Commit 086a0e5

Browse files
jhovoldgregkh
authored andcommitted
usb: dwc3: imx8mp: fix device leak at unbind
Make sure to drop the reference to the dwc3 device taken by of_find_device_by_node() on probe errors and on driver unbind. Fixes: 6dd2565 ("usb: dwc3: add imx8mp dwc3 glue layer driver") Cc: [email protected] # 5.12 Cc: Li Jun <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 22fcf88 commit 086a0e5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/usb/dwc3/dwc3-imx8mp.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,16 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
244244
IRQF_ONESHOT, dev_name(dev), dwc3_imx);
245245
if (err) {
246246
dev_err(dev, "failed to request IRQ #%d --> %d\n", irq, err);
247-
goto depopulate;
247+
goto put_dwc3;
248248
}
249249

250250
device_set_wakeup_capable(dev, true);
251251
pm_runtime_put(dev);
252252

253253
return 0;
254254

255+
put_dwc3:
256+
put_device(&dwc3_imx->dwc3->dev);
255257
depopulate:
256258
of_platform_depopulate(dev);
257259
remove_swnode:
@@ -265,8 +267,11 @@ static int dwc3_imx8mp_probe(struct platform_device *pdev)
265267

266268
static void dwc3_imx8mp_remove(struct platform_device *pdev)
267269
{
270+
struct dwc3_imx8mp *dwc3_imx = platform_get_drvdata(pdev);
268271
struct device *dev = &pdev->dev;
269272

273+
put_device(&dwc3_imx->dwc3->dev);
274+
270275
pm_runtime_get_sync(dev);
271276
of_platform_depopulate(dev);
272277
device_remove_software_node(dev);

0 commit comments

Comments
 (0)