Skip to content

Commit bab7834

Browse files
Lifeng Zhengchanwoochoi
authored andcommitted
PM / devfreq: Check governor before using governor->name
Commit 96ffcdf ("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: 96ffcdf ("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>
1 parent a98d368 commit bab7834

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

drivers/devfreq/devfreq.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,15 +1376,11 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
13761376
int ret;
13771377
struct device *dev = devfreq->dev.parent;
13781378

1379+
if (!devfreq->governor)
1380+
continue;
1381+
13791382
if (!strncmp(devfreq->governor->name, governor->name,
13801383
DEVFREQ_NAME_LEN)) {
1381-
/* we should have a devfreq governor! */
1382-
if (!devfreq->governor) {
1383-
dev_warn(dev, "%s: Governor %s NOT present\n",
1384-
__func__, governor->name);
1385-
continue;
1386-
/* Fall through */
1387-
}
13881384
ret = devfreq->governor->event_handler(devfreq,
13891385
DEVFREQ_GOV_STOP, NULL);
13901386
if (ret) {

0 commit comments

Comments
 (0)