| From 03d92778f3502f21704349fc1749ba91aaf6fb3d Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 7 Aug 2025 18:58:23 +0300 |
| Subject: PM / devfreq: mtk-cci: Fix potential error pointer dereference in |
| probe() |
| |
| From: Dan Carpenter <dan.carpenter@linaro.org> |
| |
| [ Upstream commit fc33bf0e097c6834646b98a7b3da0ae5b617f0f9 ] |
| |
| 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/ |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| drivers/devfreq/mtk-cci-devfreq.c | 3 ++- |
| 1 file changed, 2 insertions(+), 1 deletion(-) |
| |
| diff --git a/drivers/devfreq/mtk-cci-devfreq.c b/drivers/devfreq/mtk-cci-devfreq.c |
| index 22fe9e631f8aa..5730076846e1b 100644 |
| --- a/drivers/devfreq/mtk-cci-devfreq.c |
| +++ b/drivers/devfreq/mtk-cci-devfreq.c |
| @@ -386,7 +386,8 @@ static int mtk_ccifreq_probe(struct platform_device *pdev) |
| 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; |
| -- |
| 2.51.0 |
| |