On Thu, 20 May 2021 19:53:12 +0800 Tian Tao tiantao6@hisilicon.com wrote:
Found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/
Signed-off-by: Tian Tao tiantao6@hisilicon.com
Not 100% sure, but I think there is a bug in the probe error path in that it will leave the runtime pm reference count elevated if we hit the goto out_runtime_pm_put;
It has incremented the counter wtih pm_runtime_get_no_resume() but there is no put in the error path to decrement it again.
@Mauro, could you check this one as you've stared at more of these than me?
drivers/spi/spi-imx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 39dc02e3..0bf8333 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1514,9 +1514,8 @@ spi_imx_prepare_message(struct spi_master *master, struct spi_message *msg) struct spi_imx_data *spi_imx = spi_master_get_devdata(master); int ret;
- ret = pm_runtime_get_sync(spi_imx->dev);
- ret = pm_runtime_resume_and_get(spi_imx->dev); if (ret < 0) {
pm_runtime_put_noidle(spi_imx->dev);
Style in this file seems to prefer if (ret) where possible, so perhaps change it here as well?
dev_err(spi_imx->dev, "failed to enable clock\n"); return ret;
} @@ -1723,9 +1722,8 @@ static int spi_imx_remove(struct platform_device *pdev)
spi_bitbang_stop(&spi_imx->bitbang);
- ret = pm_runtime_get_sync(spi_imx->dev);
- ret = pm_runtime_resume_and_get(spi_imx->dev); if (ret < 0) {
dev_err(spi_imx->dev, "failed to enable clock\n"); return ret; }pm_runtime_put_noidle(spi_imx->dev);