From: Gustavo A. R. Silva Date: Wed, 6 Dec 2017 20:20:15 +0000 (-0600) Subject: PM / devfreq: Fix potential NULL pointer dereference in governor_store X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b72d39b1da82573654b4b4ce938cc6d3d3b89057;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git PM / devfreq: Fix potential NULL pointer dereference in governor_store [ Upstream commit 63f1e05f7fe9ca509c60154d6a833abf96eecdc9 ] df->governor is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Notice that df->governor is being null checked at line 1004: if (df->governor) {, which implies it might be null. Fix this by null checking df->governor before dereferencing it. Addresses-Coverity-ID: 1401988 ("Dereference before null check") Fixes: bcf23c79c4e4 ("PM / devfreq: Fix available_governor sysfs") Signed-off-by: Gustavo A. R. Silva Reviewed-by: Chanwoo Choi Signed-off-by: MyungJoo Ham Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 202476fbbc4c..8a411514a7c5 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -935,7 +935,8 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, if (df->governor == governor) { ret = 0; goto out; - } else if (df->governor->immutable || governor->immutable) { + } else if ((df->governor && df->governor->immutable) || + governor->immutable) { ret = -EINVAL; goto out; }