Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63f1e05f authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by MyungJoo Ham
Browse files

PM / devfreq: Fix potential NULL pointer dereference in governor_store



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: bcf23c79 ("PM / devfreq: Fix available_governor sysfs")
Signed-off-by: default avatarGustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: default avatarMyungJoo Ham <myungjoo.ham@samsung.com>
parent d1bf2d30
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -996,7 +996,8 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr,
	if (df->governor == governor) {
	if (df->governor == governor) {
		ret = 0;
		ret = 0;
		goto out;
		goto out;
	} else if (df->governor->immutable || governor->immutable) {
	} else if ((df->governor && df->governor->immutable) ||
					governor->immutable) {
		ret = -EINVAL;
		ret = -EINVAL;
		goto out;
		goto out;
	}
	}