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

PM / devfreq: Fix the bug of devfreq_add_device when governor is NULL

This patch fixes the bug of devfreq_add_device(). The devfreq device must
have the default governor. If find_devfreq_governor() returns error,
devfreq_add_device() fail to add the devfreq instance.

Fixes: 1b5c1be2c88e (PM / devfreq: map devfreq drivers to governor using name)
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Chanwoo Choi and committed by
Rafael J. Wysocki
73613b16 9932ef3c

+10 -5
+10 -5
drivers/devfreq/devfreq.c
··· 593 593 list_add(&devfreq->node, &devfreq_list); 594 594 595 595 governor = find_devfreq_governor(devfreq->governor_name); 596 - if (!IS_ERR(governor)) 597 - devfreq->governor = governor; 598 - if (devfreq->governor) 599 - err = devfreq->governor->event_handler(devfreq, 600 - DEVFREQ_GOV_START, NULL); 596 + if (IS_ERR(governor)) { 597 + dev_err(dev, "%s: Unable to find governor for the device\n", 598 + __func__); 599 + err = PTR_ERR(governor); 600 + goto err_init; 601 + } 602 + 603 + devfreq->governor = governor; 604 + err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START, 605 + NULL); 601 606 if (err) { 602 607 dev_err(dev, "%s: Unable to start governor for the device\n", 603 608 __func__);