The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling
@ 2025-09-15  6:21 Pengjie Zhang
  2025-09-16  1:10 ` Jie Zhan
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pengjie Zhang @ 2025-09-15  6:21 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park, cw00.choi
  Cc: linux-pm, linux-kernel, zhanjie9, zhenglifeng1, lihuisong,
	yubowen8, linhongye, linuxarm, jonathan.cameron, zhangpengjie2

Ensure all required data is acquired before calling dev_pm_opp_put(opp)
to maintain correct resource acquisition and release order.

Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
---
 drivers/devfreq/hisi_uncore_freq.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
index 96d1815059e3..c1ed70fa0a40 100644
--- a/drivers/devfreq/hisi_uncore_freq.c
+++ b/drivers/devfreq/hisi_uncore_freq.c
@@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
 		dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
 		return PTR_ERR(opp);
 	}
-	dev_pm_opp_put(opp);
 
 	data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
 
+	dev_pm_opp_put(opp);
+
 	return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
 }
 
-- 
2.33.0


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

* Re: [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling
  2025-09-15  6:21 [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling Pengjie Zhang
@ 2025-09-16  1:10 ` Jie Zhan
  2025-10-27  2:28 ` zhangpengjie (A)
  2025-11-20  1:30 ` zhangpengjie (A)
  2 siblings, 0 replies; 6+ messages in thread
From: Jie Zhan @ 2025-09-16  1:10 UTC (permalink / raw)
  To: Pengjie Zhang, myungjoo.ham, kyungmin.park, cw00.choi
  Cc: linux-pm, linux-kernel, zhenglifeng1, lihuisong, yubowen8,
	linhongye, linuxarm, jonathan.cameron



On 9/15/2025 2:21 PM, Pengjie Zhang wrote:
> Ensure all required data is acquired before calling dev_pm_opp_put(opp)
> to maintain correct resource acquisition and release order.
> 
> Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
> Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
> ---
>  drivers/devfreq/hisi_uncore_freq.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
Hi Pengjie,

Yeah dev_pm_opp_put() should be after dev_pm_opp_get_freq().
Thanks for spotting this.

Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com>
> 
> diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> index 96d1815059e3..c1ed70fa0a40 100644
> --- a/drivers/devfreq/hisi_uncore_freq.c
> +++ b/drivers/devfreq/hisi_uncore_freq.c
> @@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
>  		dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
>  		return PTR_ERR(opp);
>  	}
> -	dev_pm_opp_put(opp);
>  
>  	data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
>  
> +	dev_pm_opp_put(opp);
> +
>  	return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
>  }
>  

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

* Re: [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling
  2025-09-15  6:21 [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling Pengjie Zhang
  2025-09-16  1:10 ` Jie Zhan
@ 2025-10-27  2:28 ` zhangpengjie (A)
  2025-10-28 13:47   ` MyungJoo Ham
  2025-11-20  1:30 ` zhangpengjie (A)
  2 siblings, 1 reply; 6+ messages in thread
From: zhangpengjie (A) @ 2025-10-27  2:28 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park, cw00.choi
  Cc: linux-pm, linux-kernel, zhanjie9, zhenglifeng1, lihuisong,
	yubowen8, linhongye, linuxarm, jonathan.cameron

On 9/15/2025 2:21 PM, Pengjie Zhang wrote:
> Ensure all required data is acquired before calling dev_pm_opp_put(opp)
> to maintain correct resource acquisition and release order.
>
> Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
> Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
> ---
>   drivers/devfreq/hisi_uncore_freq.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> index 96d1815059e3..c1ed70fa0a40 100644
> --- a/drivers/devfreq/hisi_uncore_freq.c
> +++ b/drivers/devfreq/hisi_uncore_freq.c
> @@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
>   		dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
>   		return PTR_ERR(opp);
>   	}
> -	dev_pm_opp_put(opp);
>   
>   	data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
>   
> +	dev_pm_opp_put(opp);
> +
>   	return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
>   }

Gentle ping on this reviewed patch. 🙂

Thanks!



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

* Re: [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling
  2025-10-27  2:28 ` zhangpengjie (A)
@ 2025-10-28 13:47   ` MyungJoo Ham
  0 siblings, 0 replies; 6+ messages in thread
From: MyungJoo Ham @ 2025-10-28 13:47 UTC (permalink / raw)
  To: zhangpengjie (A)
  Cc: Kyungmin Park, Chanwoo Choi, Linux PM list, LKML, zhanjie9,
	zhenglifeng1, lihuisong, yubowen8, linhongye, linuxarm,
	jonathan.cameron

2025년 10월 27일 (월) 11:28, zhangpengjie (A) <zhangpengjie2@huawei.com>님이 작성:
>
> On 9/15/2025 2:21 PM, Pengjie Zhang wrote:
> > Ensure all required data is acquired before calling dev_pm_opp_put(opp)
> > to maintain correct resource acquisition and release order.
> >
> > Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
> > Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
> > ---
> >   drivers/devfreq/hisi_uncore_freq.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> > index 96d1815059e3..c1ed70fa0a40 100644
> > --- a/drivers/devfreq/hisi_uncore_freq.c
> > +++ b/drivers/devfreq/hisi_uncore_freq.c
> > @@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
> >               dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
> >               return PTR_ERR(opp);
> >       }
> > -     dev_pm_opp_put(opp);
> >
> >       data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
> >
> > +     dev_pm_opp_put(opp);
> > +
> >       return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
> >   }
>
> Gentle ping on this reviewed patch. 🙂
>
> Thanks!
>

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

PTAL, Chanwoo.

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

* Re: [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling
  2025-09-15  6:21 [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling Pengjie Zhang
  2025-09-16  1:10 ` Jie Zhan
  2025-10-27  2:28 ` zhangpengjie (A)
@ 2025-11-20  1:30 ` zhangpengjie (A)
  2025-11-20  5:43   ` Chanwoo Choi
  2 siblings, 1 reply; 6+ messages in thread
From: zhangpengjie (A) @ 2025-11-20  1:30 UTC (permalink / raw)
  To: myungjoo.ham, kyungmin.park, cw00.choi
  Cc: linux-pm, linux-kernel, zhanjie9, zhenglifeng1, lihuisong,
	yubowen8, linhongye, linuxarm, jonathan.cameron


Hi All,

This is a friendly follow-up on this patch.

Given that everyone is often busy with various tasks, I wanted to make
sure it doesn't fall through the cracks.

Thank you for your time and review.

Best regards,
Pengjie Zhang

On 9/15/2025 2:21 PM, Pengjie Zhang wrote:
> Ensure all required data is acquired before calling dev_pm_opp_put(opp)
> to maintain correct resource acquisition and release order.
>
> Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
> Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
> ---
>   drivers/devfreq/hisi_uncore_freq.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> index 96d1815059e3..c1ed70fa0a40 100644
> --- a/drivers/devfreq/hisi_uncore_freq.c
> +++ b/drivers/devfreq/hisi_uncore_freq.c
> @@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
>   		dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
>   		return PTR_ERR(opp);
>   	}
> -	dev_pm_opp_put(opp);
>   
>   	data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
>   
> +	dev_pm_opp_put(opp);
> +
>   	return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
>   }
>   

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

* Re: [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling
  2025-11-20  1:30 ` zhangpengjie (A)
@ 2025-11-20  5:43   ` Chanwoo Choi
  0 siblings, 0 replies; 6+ messages in thread
From: Chanwoo Choi @ 2025-11-20  5:43 UTC (permalink / raw)
  To: zhangpengjie (A)
  Cc: myungjoo.ham, kyungmin.park, cw00.choi, linux-pm, linux-kernel,
	zhanjie9, zhenglifeng1, lihuisong, yubowen8, linhongye, linuxarm,
	jonathan.cameron

Hi,

I'm sorry for late reply.

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

If you need to apply this patch to other git repository with some
related patch, I agree.

Thanks,

On Thu, Nov 20, 2025 at 10:31 AM zhangpengjie (A)
<zhangpengjie2@huawei.com> wrote:
>
>
> Hi All,
>
> This is a friendly follow-up on this patch.
>
> Given that everyone is often busy with various tasks, I wanted to make
> sure it doesn't fall through the cracks.
>
> Thank you for your time and review.
>
> Best regards,
> Pengjie Zhang
>
> On 9/15/2025 2:21 PM, Pengjie Zhang wrote:
> > Ensure all required data is acquired before calling dev_pm_opp_put(opp)
> > to maintain correct resource acquisition and release order.
> >
> > Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
> > Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
> > ---
> >   drivers/devfreq/hisi_uncore_freq.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/devfreq/hisi_uncore_freq.c b/drivers/devfreq/hisi_uncore_freq.c
> > index 96d1815059e3..c1ed70fa0a40 100644
> > --- a/drivers/devfreq/hisi_uncore_freq.c
> > +++ b/drivers/devfreq/hisi_uncore_freq.c
> > @@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
> >               dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
> >               return PTR_ERR(opp);
> >       }
> > -     dev_pm_opp_put(opp);
> >
> >       data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
> >
> > +     dev_pm_opp_put(opp);
> > +
> >       return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
> >   }
> >
>


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

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

end of thread, other threads:[~2025-11-20  5:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15  6:21 [PATCH] PM / devfreq: hisi: Fix potential UAF in OPP handling Pengjie Zhang
2025-09-16  1:10 ` Jie Zhan
2025-10-27  2:28 ` zhangpengjie (A)
2025-10-28 13:47   ` MyungJoo Ham
2025-11-20  1:30 ` zhangpengjie (A)
2025-11-20  5:43   ` Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox