public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Choi Chanwoo <cwchoi00@gmail.com>
To: Yaxiong Tian <tianyaxiong@kylinos.cn>,
	myungjoo.ham@samsung.com, kyungmin.park@samsung.com,
	cw00.choi@samsung.com, zhanjie9@hisilicon.com, nm@ti.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] PM / devfreq: Fix possible null pointer issue in devfreq_add_governor()
Date: Thu, 30 Apr 2026 06:49:07 +0900	[thread overview]
Message-ID: <267c9317-0cf3-44d5-b442-2bd713163312@gmail.com> (raw)
In-Reply-To: <20260401033046.67482-1-tianyaxiong@kylinos.cn>



2026-04-01 PM 12:30에 Yaxiong Tian 이(가) 쓴 글:
> When a user removes a governor using devfreq_remove_governor(), if
> the current device is using this governor, devfreq->governor will
> be set to NULL. When the user registers any governor
> using devfreq_add_governor(), since devfreq->governor is NULL, a
> null pointer error occurs in strncmp().
> 
> For example: A user loads the userspace gov through a module, then
> a device selects userspace. When unloading the userspace module and
> then loading it again, the null pointer error occurs:
> 
> Unable to handle kernel NULL pointer dereference at virtual address
> 0000000000000010
> Mem abort info:
> ESR = 0x0000000096000004
> EC = 0x25: DABT (current EL), IL = 32 bits
> *******************skip *********************
> Call trace:
> __pi_strncmp+0x20/0x1b8
> devfreq_userspace_init+0x1c/0xff8 [governor_userspace]
> do_one_initcall+0x4c/0x278
> do_init_module+0x5c/0x218
> load_module+0x1f1c/0x1fc8
> init_module_from_file+0x8c/0xd0
> __arm64_sys_finit_module+0x220/0x3d8
> invoke_syscall+0x48/0x110
> el0_svc_common.constprop.0+0xbc/0xe8
> do_el0_svc+0x20/0x30
> el0_svc+0x24/0xb8
> el0t_64_sync_handler+0xb8/0xc0
> el0t_64_sync+0x14c/0x150
> 
> To fix this issue, remove the list_for_each_entry() logic, as
> find_devfreq_governor() has already checked for the existence of
> governor with the same name. This makes it impossible to find a
> duplicate governor in the list, so the subsequent logic is
> unreachable and can be removed.
> 
> Fixes: 1b5c1be2c88e ("PM / devfreq: map devfreq drivers to governor using name")
> Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn>
> ---
>  drivers/devfreq/devfreq.c | 33 ---------------------------------
>  1 file changed, 33 deletions(-)
> 
> Hi Jie Zhan: 
> 	If you're willing, I'd like to add your Co-developed-by tag.
> 
> diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
> index 82dd9a43dc62..994984f7b6e1 100644
> --- a/drivers/devfreq/devfreq.c
> +++ b/drivers/devfreq/devfreq.c
> @@ -1261,7 +1261,6 @@ void devfreq_resume(void)
>  int devfreq_add_governor(struct devfreq_governor *governor)
>  {
>  	struct devfreq_governor *g;
> -	struct devfreq *devfreq;
>  	int err = 0;
>  
>  	if (!governor) {
> @@ -1280,38 +1279,6 @@ int devfreq_add_governor(struct devfreq_governor *governor)
>  
>  	list_add(&governor->node, &devfreq_governor_list);
>  
> -	list_for_each_entry(devfreq, &devfreq_list, node) {
> -		int ret = 0;
> -		struct device *dev = devfreq->dev.parent;
> -
> -		if (!strncmp(devfreq->governor->name, governor->name,
> -			     DEVFREQ_NAME_LEN)) {
> -			/* The following should never occur */
> -			if (devfreq->governor) {
> -				dev_warn(dev,
> -					 "%s: Governor %s already present\n",
> -					 __func__, devfreq->governor->name);
> -				ret = devfreq->governor->event_handler(devfreq,
> -							DEVFREQ_GOV_STOP, NULL);
> -				if (ret) {
> -					dev_warn(dev,
> -						 "%s: Governor %s stop = %d\n",
> -						 __func__,
> -						 devfreq->governor->name, ret);
> -				}
> -				/* Fall through */
> -			}
> -			devfreq->governor = governor;
> -			ret = devfreq->governor->event_handler(devfreq,
> -						DEVFREQ_GOV_START, NULL);
> -			if (ret) {
> -				dev_warn(dev, "%s: Governor %s start=%d\n",
> -					 __func__, devfreq->governor->name,
> -					 ret);
> -			}
> -		}
> -	}
> -
>  err_out:
>  	mutex_unlock(&devfreq_list_lock);
>  


Hi,

Applied it. Thanks for fixing it.

Thanks,
Chanwoo Choi



  parent reply	other threads:[~2026-04-29 21:49 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  3:28 [PATCH v2 0/4] Fix some errors in the devfreq core layer when governor is NULL Yaxiong Tian
2026-04-01  3:30 ` [PATCH v2 1/4] PM / devfreq: Fix possible null pointer issue in devfreq_add_governor() Yaxiong Tian
2026-04-02  3:06   ` Jie Zhan
2026-04-29 21:49   ` Choi Chanwoo [this message]
2026-04-01  3:30 ` [PATCH v2 2/4] PM / devfreq: Fix available_governors_show() when no governor is set Yaxiong Tian
2026-04-02  3:10   ` Jie Zhan
2026-04-29 21:49   ` Choi Chanwoo
2026-04-01  3:31 ` [PATCH v2 3/4] PM / devfreq: Fix governor_store() failing when device has no current governor Yaxiong Tian
2026-04-02  3:21   ` Jie Zhan
2026-04-02  5:47     ` Yaxiong Tian
2026-04-02  6:52       ` Jie Zhan
2026-04-29 22:28   ` Choi Chanwoo
2026-04-30  3:29     ` Yaxiong Tian
2026-04-30  3:20   ` [PATCH v3 " Yaxiong Tian
2026-04-01  3:31 ` [PATCH v2 4/4] PM / devfreq: Optimize error return value of governor_show() Yaxiong Tian
2026-04-02  3:38   ` Jie Zhan
2026-04-29 21:50   ` Choi Chanwoo
2026-04-28  2:50 ` [PATCH v2 0/4] Fix some errors in the devfreq core layer when governor is NULL Jie Zhan
2026-04-28  2:59   ` Yaxiong Tian
2026-04-29  2:04     ` Jie Zhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=267c9317-0cf3-44d5-b442-2bd713163312@gmail.com \
    --to=cwchoi00@gmail.com \
    --cc=cw00.choi@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=nm@ti.com \
    --cc=tianyaxiong@kylinos.cn \
    --cc=zhanjie9@hisilicon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox