PM / devfreq: Check NULL governor in available_governors_show
authorLeonard Crestez <leonard.crestez@nxp.com>
Tue, 24 Sep 2019 07:26:53 +0000 (10:26 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 12 Jan 2020 10:24:15 +0000 (11:24 +0100)
commit d68adc8f85cd757bd33c8d7b2660ad6f16f7f3dc upstream.

The governor is initialized after sysfs attributes become visible so in
theory the governor field can be NULL here.

Fixes: bcf23c79c4e46 ("PM / devfreq: Fix available_governor sysfs")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/devfreq/devfreq.c

index fb696957eb216e53fa4ae35cf49c29cb5f10488b..1ba9d02381e8333b70c656a6359f4bf20f37a3fc 100644 (file)
@@ -982,7 +982,7 @@ static ssize_t available_governors_show(struct device *d,
         * The devfreq with immutable governor (e.g., passive) shows
         * only own governor.
         */
-       if (df->governor->immutable) {
+       if (df->governor && df->governor->immutable) {
                count = scnprintf(&buf[count], DEVFREQ_NAME_LEN,
                                   "%s ", df->governor_name);
        /*