Skip to content

Commit e963408

Browse files
author
Russell King
committed
drivers/amba: fix reset control error handling
With commit 79bdcb2 ("ARM: 8906/1: drivers/amba: add reset control to amba bus probe") it is possible for the the amba bus driver to defer probing the device for its IDs because the reset driver may be probed later. However when a subsequent probe occurs, the call to request_resource() in the driver returns -EBUSY as the driver has not released the resource from the initial probe attempt - or cleaned up any of the preceding actions. Fix this both for the deferred probe case as well as a failure to get the reset. Fixes: 79bdcb2 ("ARM: 8906/1: drivers/amba: add reset control to amba bus probe") Reported-by: Dinh Nguyen <dinguyen@kernel.org> Tested-by: Dinh Nguyen <dinguyen@kernel.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent 79bdcb2 commit e963408

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎drivers/amba/bus.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,11 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
409409
*/
410410
rstc = of_reset_control_array_get_optional_shared(dev->dev.of_node);
411411
if (IS_ERR(rstc)) {
412-
if (PTR_ERR(rstc) != -EPROBE_DEFER)
413-
dev_err(&dev->dev, "Can't get amba reset!\n");
414-
return PTR_ERR(rstc);
412+
ret = PTR_ERR(rstc);
413+
if (ret != -EPROBE_DEFER)
414+
dev_err(&dev->dev, "can't get reset: %d\n",
415+
ret);
416+
goto err_reset;
415417
}
416418
reset_control_deassert(rstc);
417419
reset_control_put(rstc);
@@ -472,6 +474,12 @@ static int amba_device_try_add(struct amba_device *dev, struct resource *parent)
472474
release_resource(&dev->res);
473475
err_out:
474476
return ret;
477+
478+
err_reset:
479+
amba_put_disable_pclk(dev);
480+
iounmap(tmp);
481+
dev_pm_domain_detach(&dev->dev, true);
482+
goto err_release;
475483
}
476484

477485
/*

0 commit comments

Comments
 (0)