mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
soc: ti: Fix reference imbalance in knav_dma_probe
The patch fix two reference leak.
1) pm_runtime_get_sync will increment pm usage counter even it
failed. Forgetting to call put operation will result in
reference leak.
2) The pm_runtime_enable will increase power disable depth. Thus
a pairing decrement is needed on the error handling path to
keep it balanced.
We fix it by: 1) adding call pm_runtime_put_noidle or
pm_runtime_put_sync in error handling. 2) adding pm_runtime_disable
in error handling, to keep usage counter and disable depth balanced.
Fixes: 88139ed030
("soc: ti: add Keystone Navigator DMA support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
This commit is contained in:
parent
8465c7d100
commit
b4fa73358c
1 changed files with 11 additions and 2 deletions
|
@ -749,8 +749,9 @@ static int knav_dma_probe(struct platform_device *pdev)
|
||||||
pm_runtime_enable(kdev->dev);
|
pm_runtime_enable(kdev->dev);
|
||||||
ret = pm_runtime_get_sync(kdev->dev);
|
ret = pm_runtime_get_sync(kdev->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
pm_runtime_put_noidle(kdev->dev);
|
||||||
dev_err(kdev->dev, "unable to enable pktdma, err %d\n", ret);
|
dev_err(kdev->dev, "unable to enable pktdma, err %d\n", ret);
|
||||||
return ret;
|
goto err_pm_disable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialise all packet dmas */
|
/* Initialise all packet dmas */
|
||||||
|
@ -764,7 +765,8 @@ static int knav_dma_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
if (list_empty(&kdev->list)) {
|
if (list_empty(&kdev->list)) {
|
||||||
dev_err(dev, "no valid dma instance\n");
|
dev_err(dev, "no valid dma instance\n");
|
||||||
return -ENODEV;
|
ret = -ENODEV;
|
||||||
|
goto err_put_sync;
|
||||||
}
|
}
|
||||||
|
|
||||||
debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
|
debugfs_create_file("knav_dma", S_IFREG | S_IRUGO, NULL, NULL,
|
||||||
|
@ -772,6 +774,13 @@ static int knav_dma_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
device_ready = true;
|
device_ready = true;
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
err_put_sync:
|
||||||
|
pm_runtime_put_sync(kdev->dev);
|
||||||
|
err_pm_disable:
|
||||||
|
pm_runtime_disable(kdev->dev);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int knav_dma_remove(struct platform_device *pdev)
|
static int knav_dma_remove(struct platform_device *pdev)
|
||||||
|
|
Loading…
Reference in a new issue