summaryrefslogtreecommitdiff
path: root/drivers/devfreq
diff options
context:
space:
mode:
authorLifeng Zheng <zhenglifeng1@huawei.com>2025-04-21 11:00:20 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-15 16:38:33 +0200
commit75323a49aa603cf5484a6d74d0d329e86d756e11 (patch)
tree5f272aed09621cc5f6715215d1e3558930408074 /drivers/devfreq
parentc0a1ee6dd5719550d3bc109c90a2d6b50b1ed8f7 (diff)
downloadlinux-75323a49aa603cf5484a6d74d0d329e86d756e11.tar.gz
linux-75323a49aa603cf5484a6d74d0d329e86d756e11.tar.bz2
linux-75323a49aa603cf5484a6d74d0d329e86d756e11.zip
PM / devfreq: Check governor before using governor->name
[ Upstream commit bab7834c03820eb11269bc48f07c3800192460d2 ] Commit 96ffcdf239de ("PM / devfreq: Remove redundant governor_name from struct devfreq") removes governor_name and uses governor->name to replace it. But devfreq->governor may be NULL and directly using devfreq->governor->name may cause null pointer exception. Move the check of governor to before using governor->name. Fixes: 96ffcdf239de ("PM / devfreq: Remove redundant governor_name from struct devfreq") Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com> Link: https://lore.kernel.org/lkml/20250421030020.3108405-5-zhenglifeng1@huawei.com/ Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/devfreq')
-rw-r--r--drivers/devfreq/devfreq.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 98657d3b9435..713e6e52cca1 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -1382,15 +1382,11 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
int ret;
struct device *dev = devfreq->dev.parent;
+ if (!devfreq->governor)
+ continue;
+
if (!strncmp(devfreq->governor->name, governor->name,
DEVFREQ_NAME_LEN)) {
- /* we should have a devfreq governor! */
- if (!devfreq->governor) {
- dev_warn(dev, "%s: Governor %s NOT present\n",
- __func__, governor->name);
- continue;
- /* Fall through */
- }
ret = devfreq->governor->event_handler(devfreq,
DEVFREQ_GOV_STOP, NULL);
if (ret) {