]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PM / devfreq: mtk-cci: Fix potential error pointer dereference in probe()
authorDan Carpenter <dan.carpenter@linaro.org>
Thu, 7 Aug 2025 15:58:23 +0000 (18:58 +0300)
committerChanwoo Choi <cw00.choi@samsung.com>
Sat, 6 Sep 2025 16:15:17 +0000 (01:15 +0900)
The drv->sram_reg pointer could be set to ERR_PTR(-EPROBE_DEFER) which
would lead to a error pointer dereference.  Use IS_ERR_OR_NULL() to check
that the pointer is valid.

Fixes: e09bd5757b52 ("PM / devfreq: mtk-cci: Handle sram regulator probe deferral")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Link: https://patchwork.kernel.org/project/linux-pm/patch/aJTNHz8kk8s6Q2os@stanley.mountain/
drivers/devfreq/mtk-cci-devfreq.c

index 22fe9e631f8aaf4808afdd4a1a1cf300d026010a..5730076846e1be9f43cdd6891dac477a8cee5a71 100644 (file)
@@ -386,7 +386,8 @@ out_disable_cci_clk:
 out_free_resources:
        if (regulator_is_enabled(drv->proc_reg))
                regulator_disable(drv->proc_reg);
-       if (drv->sram_reg && regulator_is_enabled(drv->sram_reg))
+       if (!IS_ERR_OR_NULL(drv->sram_reg) &&
+           regulator_is_enabled(drv->sram_reg))
                regulator_disable(drv->sram_reg);
 
        return ret;