public inbox for linux-clk@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference
@ 2023-12-12  9:21 Dan Carpenter
  2023-12-12 11:10 ` Abel Vesa
  2023-12-17 17:20 ` Bjorn Andersson
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-12-12  9:21 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: Bjorn Andersson, Andy Gross, Konrad Dybcio, Michael Turquette,
	Stephen Boyd, linux-arm-msm, linux-clk, kernel-janitors

If "regmap" is an error pointer then calling regmap_update_bits() will
crash.  We only need to call regmap_update_bits() if we had written to
it earlier.

Fixes: ff93872a9c61 ("clk: qcom: camcc-sc8280xp: Add sc8280xp CAMCC")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/clk/qcom/camcc-sc8280xp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/qcom/camcc-sc8280xp.c b/drivers/clk/qcom/camcc-sc8280xp.c
index 877341e7327e..3dcd79b01515 100644
--- a/drivers/clk/qcom/camcc-sc8280xp.c
+++ b/drivers/clk/qcom/camcc-sc8280xp.c
@@ -3017,14 +3017,15 @@ static int camcc_sc8280xp_probe(struct platform_device *pdev)
 
 	ret = qcom_cc_really_probe(pdev, &camcc_sc8280xp_desc, regmap);
 	if (ret)
-		goto err_put_rpm;
+		goto err_disable;
 
 	pm_runtime_put(&pdev->dev);
 
 	return 0;
 
-err_put_rpm:
+err_disable:
 	regmap_update_bits(regmap, 0xc1e4, BIT(0), 0);
+err_put_rpm:
 	pm_runtime_put_sync(&pdev->dev);
 
 	return ret;
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference
  2023-12-12  9:21 [PATCH] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference Dan Carpenter
@ 2023-12-12 11:10 ` Abel Vesa
  2023-12-17 17:20 ` Bjorn Andersson
  1 sibling, 0 replies; 3+ messages in thread
From: Abel Vesa @ 2023-12-12 11:10 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Bryan O'Donoghue, Bjorn Andersson, Andy Gross, Konrad Dybcio,
	Michael Turquette, Stephen Boyd, linux-arm-msm, linux-clk,
	kernel-janitors

On 23-12-12 12:21:51, Dan Carpenter wrote:
> If "regmap" is an error pointer then calling regmap_update_bits() will
> crash.  We only need to call regmap_update_bits() if we had written to
> it earlier.
> 
> Fixes: ff93872a9c61 ("clk: qcom: camcc-sc8280xp: Add sc8280xp CAMCC")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Abel Vesa <abel.vesa@linaro.org>

> ---
>  drivers/clk/qcom/camcc-sc8280xp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/clk/qcom/camcc-sc8280xp.c b/drivers/clk/qcom/camcc-sc8280xp.c
> index 877341e7327e..3dcd79b01515 100644
> --- a/drivers/clk/qcom/camcc-sc8280xp.c
> +++ b/drivers/clk/qcom/camcc-sc8280xp.c
> @@ -3017,14 +3017,15 @@ static int camcc_sc8280xp_probe(struct platform_device *pdev)
>  
>  	ret = qcom_cc_really_probe(pdev, &camcc_sc8280xp_desc, regmap);
>  	if (ret)
> -		goto err_put_rpm;
> +		goto err_disable;
>  
>  	pm_runtime_put(&pdev->dev);
>  
>  	return 0;
>  
> -err_put_rpm:
> +err_disable:
>  	regmap_update_bits(regmap, 0xc1e4, BIT(0), 0);
> +err_put_rpm:
>  	pm_runtime_put_sync(&pdev->dev);
>  
>  	return ret;
> -- 
> 2.42.0
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference
  2023-12-12  9:21 [PATCH] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference Dan Carpenter
  2023-12-12 11:10 ` Abel Vesa
@ 2023-12-17 17:20 ` Bjorn Andersson
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2023-12-17 17:20 UTC (permalink / raw)
  To: Bryan O'Donoghue, Dan Carpenter
  Cc: Andy Gross, Konrad Dybcio, Michael Turquette, Stephen Boyd,
	linux-arm-msm, linux-clk, kernel-janitors


On Tue, 12 Dec 2023 12:21:51 +0300, Dan Carpenter wrote:
> If "regmap" is an error pointer then calling regmap_update_bits() will
> crash.  We only need to call regmap_update_bits() if we had written to
> it earlier.
> 
> 

Applied, thanks!

[1/1] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference
      commit: df14d214105e29d0e734aa36445888bd2b0dde78

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-17 17:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12  9:21 [PATCH] clk: qcom: camcc-sc8280xp: Prevent error pointer dereference Dan Carpenter
2023-12-12 11:10 ` Abel Vesa
2023-12-17 17:20 ` Bjorn Andersson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox