diff options
author | Ezequiel Garcia <ezequiel@collabora.com> | 2019-06-21 18:39:49 -0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-10-05 13:13:47 +0200 |
commit | 7f6346e814ec1f723003b7b9ac7805dfbabb108a (patch) | |
tree | b048f066780a9be7595a32343a328ae360ad8a70 | |
parent | 0ac4a7a4562bb2dcf9419ac2513cd744374ebc87 (diff) | |
download | linux-stable-7f6346e814ec1f723003b7b9ac7805dfbabb108a.tar.gz linux-stable-7f6346e814ec1f723003b7b9ac7805dfbabb108a.tar.bz2 linux-stable-7f6346e814ec1f723003b7b9ac7805dfbabb108a.zip |
PM / devfreq: Fix kernel oops on governor module load
[ Upstream commit 7544fd7f384591038646d3cd9efb311ab4509e24 ]
A bit unexpectedly (but still documented), request_module may
return a positive value, in case of a modprobe error.
This is currently causing issues in the devfreq framework.
When a request_module exits with a positive value, we currently
return that via ERR_PTR. However, because the value is positive,
it's not a ERR_VALUE proper, and is therefore treated as a
valid struct devfreq_governor pointer, leading to a kernel oops.
Fix this by returning -EINVAL if request_module returns a positive
value.
Fixes: b53b0128052ff ("PM / devfreq: Fix static checker warning in try_then_request_governor")
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/devfreq/devfreq.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index ab22bf8a12d6..a0e19802149f 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -254,7 +254,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name) /* Restore previous state before return */ mutex_lock(&devfreq_list_lock); if (err) - return ERR_PTR(err); + return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL); governor = find_devfreq_governor(name); } |