diff mbox series

clk: qcom: camcc-sc8280xp: Prevent error pointer dereference

Message ID 210d48ce-6ebc-4a6b-b30f-866d10d41a16@moroto.mountain (mailing list archive)
State Awaiting Upstream, archived
Headers show
Series clk: qcom: camcc-sc8280xp: Prevent error pointer dereference | expand

Commit Message

Dan Carpenter Dec. 12, 2023, 9:21 a.m. UTC
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(-)

Comments

Abel Vesa Dec. 12, 2023, 11:10 a.m. UTC | #1
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
> 
>
Bjorn Andersson Dec. 17, 2023, 5:20 p.m. UTC | #2
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,
diff mbox series

Patch

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;