Skip to content

Commit 1473e9e

Browse files
jhovoldgregkh
authored andcommitted
usb: musb: omap2430: fix device leak at unbind
Make sure to drop the reference to the control device taken by of_find_device_by_node() during probe when the driver is unbound. Fixes: 8934d3e ("usb: musb: omap2430: Don't use omap_get_control_dev()") Cc: [email protected] # 3.13 Cc: Roger Quadros <[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 868837b commit 1473e9e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/usb/musb/omap2430.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static int omap2430_probe(struct platform_device *pdev)
400400
ret = platform_device_add_resources(musb, pdev->resource, pdev->num_resources);
401401
if (ret) {
402402
dev_err(&pdev->dev, "failed to add resources\n");
403-
goto err2;
403+
goto err_put_control_otghs;
404404
}
405405

406406
if (populate_irqs) {
@@ -413,7 +413,7 @@ static int omap2430_probe(struct platform_device *pdev)
413413
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
414414
if (!res) {
415415
ret = -EINVAL;
416-
goto err2;
416+
goto err_put_control_otghs;
417417
}
418418

419419
musb_res[i].start = res->start;
@@ -441,14 +441,14 @@ static int omap2430_probe(struct platform_device *pdev)
441441
ret = platform_device_add_resources(musb, musb_res, i);
442442
if (ret) {
443443
dev_err(&pdev->dev, "failed to add IRQ resources\n");
444-
goto err2;
444+
goto err_put_control_otghs;
445445
}
446446
}
447447

448448
ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
449449
if (ret) {
450450
dev_err(&pdev->dev, "failed to add platform_data\n");
451-
goto err2;
451+
goto err_put_control_otghs;
452452
}
453453

454454
pm_runtime_enable(glue->dev);
@@ -463,7 +463,9 @@ static int omap2430_probe(struct platform_device *pdev)
463463

464464
err3:
465465
pm_runtime_disable(glue->dev);
466-
466+
err_put_control_otghs:
467+
if (!IS_ERR(glue->control_otghs))
468+
put_device(glue->control_otghs);
467469
err2:
468470
platform_device_put(musb);
469471

@@ -477,6 +479,8 @@ static void omap2430_remove(struct platform_device *pdev)
477479

478480
platform_device_unregister(glue->musb);
479481
pm_runtime_disable(glue->dev);
482+
if (!IS_ERR(glue->control_otghs))
483+
put_device(glue->control_otghs);
480484
}
481485

482486
#ifdef CONFIG_PM

0 commit comments

Comments
 (0)