Skip to contentSkip to conversation

Patch "PM / devfreq: Fix potential NULL pointer dereference in governor_store" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Apr 9, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

PM / devfreq: Fix potential NULL pointer dereference in governor_store

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
pm-devfreq-fix-potential-null-pointer-dereference-in-governor_store.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Mon Apr 9 13:58:16 CEST 2018

From: "Gustavo A. R. Silva" <[email protected]>
Date: Wed, 6 Dec 2017 14:20:15 -0600
Subject: PM / devfreq: Fix potential NULL pointer dereference in governor_store

From: "Gustavo A. R. Silva" <[email protected]>

[ 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")
---
 drivers/devfreq/devfreq.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/devfreq/devfreq.c +2 -1
@@ -935,7 +935,8 @@ static ssize_t governor_store(struct dev
 	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;
 	}

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/pm-devfreq-fix-potential-null-pointer-dereference-in-governor_store.patch