Commit 7544fd7f authored by Ezequiel Garcia's avatar Ezequiel Garcia Committed by MyungJoo Ham

PM / devfreq: Fix kernel oops on governor module load

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: b53b0128 ("PM / devfreq: Fix static checker warning in try_then_request_governor")
Signed-off-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
Reviewed-by: default avatarChanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: default avatarMyungJoo Ham <myungjoo.ham@samsung.com>
parent 0a453aca
...@@ -254,7 +254,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name) ...@@ -254,7 +254,7 @@ static struct devfreq_governor *try_then_request_governor(const char *name)
/* Restore previous state before return */ /* Restore previous state before return */
mutex_lock(&devfreq_list_lock); mutex_lock(&devfreq_list_lock);
if (err) if (err)
return ERR_PTR(err); return (err < 0) ? ERR_PTR(err) : ERR_PTR(-EINVAL);
governor = find_devfreq_governor(name); governor = find_devfreq_governor(name);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment