Commit 0947f6f6 authored by Navid Emamdoost's avatar Navid Emamdoost Committed by Sasha Levin

sata_rcar: handle pm_runtime_get_sync failure cases

[ Upstream commit eea12388 ]

Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count. Call pm_runtime_put if
pm_runtime_get_sync fails.
Signed-off-by: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent e852bdcc
...@@ -909,7 +909,7 @@ static int sata_rcar_probe(struct platform_device *pdev) ...@@ -909,7 +909,7 @@ static int sata_rcar_probe(struct platform_device *pdev)
pm_runtime_enable(dev); pm_runtime_enable(dev);
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
if (ret < 0) if (ret < 0)
goto err_pm_disable; goto err_pm_put;
host = ata_host_alloc(dev, 1); host = ata_host_alloc(dev, 1);
if (!host) { if (!host) {
...@@ -940,7 +940,6 @@ static int sata_rcar_probe(struct platform_device *pdev) ...@@ -940,7 +940,6 @@ static int sata_rcar_probe(struct platform_device *pdev)
err_pm_put: err_pm_put:
pm_runtime_put(dev); pm_runtime_put(dev);
err_pm_disable:
pm_runtime_disable(dev); pm_runtime_disable(dev);
return ret; return ret;
} }
...@@ -994,8 +993,10 @@ static int sata_rcar_resume(struct device *dev) ...@@ -994,8 +993,10 @@ static int sata_rcar_resume(struct device *dev)
int ret; int ret;
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put(dev);
return ret; return ret;
}
if (priv->type == RCAR_GEN3_SATA) { if (priv->type == RCAR_GEN3_SATA) {
sata_rcar_init_module(priv); sata_rcar_init_module(priv);
...@@ -1020,8 +1021,10 @@ static int sata_rcar_restore(struct device *dev) ...@@ -1020,8 +1021,10 @@ static int sata_rcar_restore(struct device *dev)
int ret; int ret;
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
if (ret < 0) if (ret < 0) {
pm_runtime_put(dev);
return ret; return ret;
}
sata_rcar_setup_port(host); sata_rcar_setup_port(host);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment