Skip to content

Commit

Permalink
PM / devfreq: Fix potential NULL pointer dereference in governor_store
Browse files Browse the repository at this point in the history
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: bcf23c7 ("PM / devfreq: Fix available_governor sysfs")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
  • Loading branch information
Gustavo A. R. Silva authored and MyungJoo Ham committed Jan 2, 2018
1 parent d1bf2d3 commit 63f1e05
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/devfreq/devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,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;
}
Expand Down

0 comments on commit 63f1e05

Please sign in to comment.