Skip to content

Commit

Permalink
media: platform: stm32: unprepare clocks at handling errors in probe
Browse files Browse the repository at this point in the history
[ Upstream commit 055d2db ]

stm32_cec_probe() did not unprepare clocks on error handling paths. The
patch fixes that.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
eunovm authored and gregkh committed Sep 18, 2021
1 parent 6fa9732 commit 9dc8dc2
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions drivers/media/cec/platform/stm32/stm32-cec.c
Expand Up @@ -305,14 +305,16 @@ static int stm32_cec_probe(struct platform_device *pdev)

cec->clk_hdmi_cec = devm_clk_get(&pdev->dev, "hdmi-cec");
if (IS_ERR(cec->clk_hdmi_cec) &&
PTR_ERR(cec->clk_hdmi_cec) == -EPROBE_DEFER)
return -EPROBE_DEFER;
PTR_ERR(cec->clk_hdmi_cec) == -EPROBE_DEFER) {
ret = -EPROBE_DEFER;
goto err_unprepare_cec_clk;
}

if (!IS_ERR(cec->clk_hdmi_cec)) {
ret = clk_prepare(cec->clk_hdmi_cec);
if (ret) {
dev_err(&pdev->dev, "Can't prepare hdmi-cec clock\n");
return ret;
goto err_unprepare_cec_clk;
}
}

Expand All @@ -324,19 +326,27 @@ static int stm32_cec_probe(struct platform_device *pdev)
CEC_NAME, caps, CEC_MAX_LOG_ADDRS);
ret = PTR_ERR_OR_ZERO(cec->adap);
if (ret)
return ret;
goto err_unprepare_hdmi_cec_clk;

ret = cec_register_adapter(cec->adap, &pdev->dev);
if (ret) {
cec_delete_adapter(cec->adap);
return ret;
}
if (ret)
goto err_delete_adapter;

cec_hw_init(cec);

platform_set_drvdata(pdev, cec);

return 0;

err_delete_adapter:
cec_delete_adapter(cec->adap);

err_unprepare_hdmi_cec_clk:
clk_unprepare(cec->clk_hdmi_cec);

err_unprepare_cec_clk:
clk_unprepare(cec->clk_cec);
return ret;
}

static int stm32_cec_remove(struct platform_device *pdev)
Expand Down

0 comments on commit 9dc8dc2

Please sign in to comment.