All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] PM / devfreq: Fix kernel oops on governor module load
@ 2019-06-21 21:39 Ezequiel Garcia
  2019-06-22 10:46 ` Chanwoo Choi
       [not found] ` <CGME20190621214003epcas5p4682d7d258b3ec2ae92521111fe8864ab@epcms1p2>
  0 siblings, 2 replies; 5+ messages in thread
From: Ezequiel Garcia @ 2019-06-21 21:39 UTC (permalink / raw)
  To: Kyungmin Park, MyungJoo Ham, Chanwoo Choi
  Cc: kernel, linux-pm, Enric Balletbo i Serra, Ezequiel Garcia

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>
---
Changes from v1:
* Rework the fix as suggested by Enric and Chanwoo,
  handling the return vaue.
---
 drivers/devfreq/devfreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 6b6991f0e873..258f70c1e48f 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -257,7 +257,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);
 	}
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM / devfreq: Fix kernel oops on governor module load
  2019-06-21 21:39 [PATCH v2] PM / devfreq: Fix kernel oops on governor module load Ezequiel Garcia
@ 2019-06-22 10:46 ` Chanwoo Choi
  2019-07-10 18:30   ` Ezequiel Garcia
       [not found] ` <CGME20190621214003epcas5p4682d7d258b3ec2ae92521111fe8864ab@epcms1p2>
  1 sibling, 1 reply; 5+ messages in thread
From: Chanwoo Choi @ 2019-06-22 10:46 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Kyungmin Park, MyungJoo Ham, Chanwoo Choi, kernel, Linux PM list,
	Enric Balletbo i Serra

Hi,

2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <ezequiel@collabora.com>님이 작성:
>
> 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>
> ---
> Changes from v1:
> * Rework the fix as suggested by Enric and Chanwoo,
>   handling the return vaue.
> ---
>  drivers/devfreq/devfreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 6b6991f0e873..258f70c1e48f 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -257,7 +257,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);
>         }

Thanks you for fix-up.
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>

But, you are missing the stable mailing list. In order to apply this
fix-up patch,\
you have to send it to stable mailing list. Please send it.


-- 
Best Regards,
Chanwoo Choi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH v2] PM / devfreq: Fix kernel oops on governor module load
       [not found] ` <CGME20190621214003epcas5p4682d7d258b3ec2ae92521111fe8864ab@epcms1p2>
@ 2019-06-24  7:37   ` MyungJoo Ham
  0 siblings, 0 replies; 5+ messages in thread
From: MyungJoo Ham @ 2019-06-24  7:37 UTC (permalink / raw)
  To: Kyungmin Park, Chanwoo Choi
  Cc: kernel, linux-pm, Enric Balletbo i Serra, Ezequiel Garcia

> 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>
> ---
> Changes from v1:
> * Rework the fix as suggested by Enric and Chanwoo,
>   handling the return vaue.
> ---
>  drivers/devfreq/devfreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM / devfreq: Fix kernel oops on governor module load
  2019-06-22 10:46 ` Chanwoo Choi
@ 2019-07-10 18:30   ` Ezequiel Garcia
  2019-07-11  2:49     ` Chanwoo Choi
  0 siblings, 1 reply; 5+ messages in thread
From: Ezequiel Garcia @ 2019-07-10 18:30 UTC (permalink / raw)
  To: cwchoi00
  Cc: Kyungmin Park, MyungJoo Ham, Chanwoo Choi, kernel, Linux PM list,
	Enric Balletbo i Serra

Hello Chanwoo,

On Sat, 2019-06-22 at 19:46 +0900, Chanwoo Choi wrote:
> Hi,
> 
> 2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <ezequiel@collabora.com>님이 작성:
> > 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>
> > ---
> > Changes from v1:
> > * Rework the fix as suggested by Enric and Chanwoo,
> >   handling the return vaue.
> > ---
> >  drivers/devfreq/devfreq.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> > index 6b6991f0e873..258f70c1e48f 100644
> > --- a/drivers/devfreq/devfreq.c
> > +++ b/drivers/devfreq/devfreq.c
> > @@ -257,7 +257,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);
> >         }
> 
> Thanks you for fix-up.
> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
> 
> But, you are missing the stable mailing list. In order to apply this
> fix-up patch,\
> you have to send it to stable mailing list. Please send it.
> 
> 

If I understand correctly, you or any of the devfreq maintainer
can simply add a Cc: stable@vger.kernel.org tag.

This is documented as Option 1 in stable-kernel-rules.rst.

The Acked-by and Reviewed-by tags need to be collected anyway :-)

Thanks!
Eze


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] PM / devfreq: Fix kernel oops on governor module load
  2019-07-10 18:30   ` Ezequiel Garcia
@ 2019-07-11  2:49     ` Chanwoo Choi
  0 siblings, 0 replies; 5+ messages in thread
From: Chanwoo Choi @ 2019-07-11  2:49 UTC (permalink / raw)
  To: Ezequiel Garcia, cwchoi00
  Cc: Kyungmin Park, MyungJoo Ham, kernel, Linux PM list,
	Enric Balletbo i Serra

Hi,

On 19. 7. 11. 오전 3:30, Ezequiel Garcia wrote:
> Hello Chanwoo,
> 
> On Sat, 2019-06-22 at 19:46 +0900, Chanwoo Choi wrote:
>> Hi,
>>
>> 2019년 6월 22일 (토) 오전 6:42, Ezequiel Garcia <ezequiel@collabora.com>님이 작성:
>>> 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>
>>> ---
>>> Changes from v1:
>>> * Rework the fix as suggested by Enric and Chanwoo,
>>>   handling the return vaue.
>>> ---
>>>  drivers/devfreq/devfreq.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
>>> index 6b6991f0e873..258f70c1e48f 100644
>>> --- a/drivers/devfreq/devfreq.c
>>> +++ b/drivers/devfreq/devfreq.c
>>> @@ -257,7 +257,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);
>>>         }
>>
>> Thanks you for fix-up.
>> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
>>
>> But, you are missing the stable mailing list. In order to apply this
>> fix-up patch,\
>> you have to send it to stable mailing list. Please send it.
>>
>>
> 
> If I understand correctly, you or any of the devfreq maintainer
> can simply add a Cc: stable@vger.kernel.org tag.

Originally, the author have to send the stable mailing list
with the required style. You can do it.

> 
> This is documented as Option 1 in stable-kernel-rules.rst.
> 
> The Acked-by and Reviewed-by tags need to be collected anyway :-)

This patch[1] was picked to devfreq.git.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/mzx/devfreq.git/commit/?h=for-next&id=4f065f69ebc2bdf1fbe224816a3c471babd370dd

> 
> Thanks!
> Eze
> 
> 
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-11  2:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-21 21:39 [PATCH v2] PM / devfreq: Fix kernel oops on governor module load Ezequiel Garcia
2019-06-22 10:46 ` Chanwoo Choi
2019-07-10 18:30   ` Ezequiel Garcia
2019-07-11  2:49     ` Chanwoo Choi
     [not found] ` <CGME20190621214003epcas5p4682d7d258b3ec2ae92521111fe8864ab@epcms1p2>
2019-06-24  7:37   ` MyungJoo Ham

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.