PM / devfreq: Fix potential NULL pointer dereference in governor_store
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Wed, 6 Dec 2017 20:20:15 +0000 (14:20 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Apr 2018 17:48:09 +0000 (19:48 +0200)
commit715f7e3efef0227865162b00d13321431be7962f
tree66021660a5b2c9e7a963f7ebba9acbe7106bbf00
parent3aa66ba53e65ba53529fd07e1cdde5063b6a2c5a
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 <garsilva@embeddedor.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/devfreq/devfreq.c