Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM / devfreq: Check governor before using governor->name

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>

authored by

Lifeng Zheng and committed by
Chanwoo Choi
bab7834c a98d3680

+3 -7
+3 -7
drivers/devfreq/devfreq.c
··· 1376 1376 int ret; 1377 1377 struct device *dev = devfreq->dev.parent; 1378 1378 1379 + if (!devfreq->governor) 1380 + continue; 1381 + 1379 1382 if (!strncmp(devfreq->governor->name, governor->name, 1380 1383 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 - } 1388 1384 ret = devfreq->governor->event_handler(devfreq, 1389 1385 DEVFREQ_GOV_STOP, NULL); 1390 1386 if (ret) {