Re: [PATCH] PM / devfreq: Fix potential NULL pointer dereference in governor_store

From: Gustavo A. R. Silva
Date: Thu Dec 07 2017 - 18:57:49 EST



Quoting MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>:

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@xxxxxxxxxxxxxx>

Acked-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>


Thank you, MyungJoo

--
Gustavo A. R. Silva