* [PATCH next] PM / devfreq: Fix double free in devfreq_event_add_edev()
@ 2025-09-09 10:29 Dan Carpenter
2025-09-09 11:55 ` Kumar, Kaushlendra
2025-09-09 14:30 ` Chanwoo Choi
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-09-09 10:29 UTC (permalink / raw)
To: Kaushlendra Kumar
Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, linux-pm, linux-kernel,
kernel-janitors
The put_device() function calls devfreq_event_release_edev() which frees
"evdev". Calling kfree() again is a double free.
Fixes: 430a1845c804 ("PM / devfreq: Fix memory leak in devfreq_event_add_edev()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/devfreq/devfreq-event.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c
index 34406c52b845..70219099c604 100644
--- a/drivers/devfreq/devfreq-event.c
+++ b/drivers/devfreq/devfreq-event.c
@@ -328,7 +328,6 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
ret = device_register(&edev->dev);
if (ret < 0) {
put_device(&edev->dev);
- kfree(edev);
return ERR_PTR(ret);
}
dev_set_drvdata(&edev->dev, edev);
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH next] PM / devfreq: Fix double free in devfreq_event_add_edev()
2025-09-09 10:29 [PATCH next] PM / devfreq: Fix double free in devfreq_event_add_edev() Dan Carpenter
@ 2025-09-09 11:55 ` Kumar, Kaushlendra
2025-09-09 14:30 ` Chanwoo Choi
1 sibling, 0 replies; 3+ messages in thread
From: Kumar, Kaushlendra @ 2025-09-09 11:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Hi Dan,
On [Date], Dan Carpenter <dan.carpenter@linaro.org> wrote:
> The put_device() function calls devfreq_event_release_edev() which frees "evdev". Calling kfree() again is a double free.
>
> Fixes: 430a1845c804 ("PM / devfreq: Fix memory leak in devfreq_event_add_edev()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/devfreq/devfreq-event.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c index 34406c52b845..70219099c604 100644
> --- a/drivers/devfreq/devfreq-event.c
> +++ b/drivers/devfreq/devfreq-event.c
> @@ -328,7 +328,6 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
> ret = device_register(&edev->dev);
> if (ret < 0) {
> put_device(&edev->dev);
> - kfree(edev);
> return ERR_PTR(ret);
> }
> dev_set_drvdata(&edev->dev, edev);
Thank you for catching this double-free issue! You're absolutely right -
the release function handles the memory cleanup, making the explicit kfree()
incorrect.
Reviewed-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Best regards,
Kaushlendra Kumar
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH next] PM / devfreq: Fix double free in devfreq_event_add_edev()
2025-09-09 10:29 [PATCH next] PM / devfreq: Fix double free in devfreq_event_add_edev() Dan Carpenter
2025-09-09 11:55 ` Kumar, Kaushlendra
@ 2025-09-09 14:30 ` Chanwoo Choi
1 sibling, 0 replies; 3+ messages in thread
From: Chanwoo Choi @ 2025-09-09 14:30 UTC (permalink / raw)
To: Dan Carpenter, Kaushlendra Kumar
Cc: Chanwoo Choi, MyungJoo Ham, Kyungmin Park, linux-pm, linux-kernel,
kernel-janitors
25. 9. 9. 19:29에 Dan Carpenter 이(가) 쓴 글:
> The put_device() function calls devfreq_event_release_edev() which frees
> "evdev". Calling kfree() again is a double free.
>
> Fixes: 430a1845c804 ("PM / devfreq: Fix memory leak in devfreq_event_add_edev()")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/devfreq/devfreq-event.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/devfreq/devfreq-event.c b/drivers/devfreq/devfreq-event.c
> index 34406c52b845..70219099c604 100644
> --- a/drivers/devfreq/devfreq-event.c
> +++ b/drivers/devfreq/devfreq-event.c
> @@ -328,7 +328,6 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
> ret = device_register(&edev->dev);
> if (ret < 0) {
> put_device(&edev->dev);
> - kfree(edev);
> return ERR_PTR(ret);
> }
> dev_set_drvdata(&edev->dev, edev);
Firstly, I'm sorry that it my wrong review of patch[1].
[1] https://patchwork.kernel.org/project/linux-pm/patch/20250907113302.3353584-1-kaushlendra.kumar@intel.com/
As you mentioned, the above patch[1] doesn't be necessary.
Instead of applying your patch, I'll drop the patch[1].
I'm sorry to make the confusion.
--
Best Regards,
Samsung Electronics
Chanwoo Choi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-09 14:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-09 10:29 [PATCH next] PM / devfreq: Fix double free in devfreq_event_add_edev() Dan Carpenter
2025-09-09 11:55 ` Kumar, Kaushlendra
2025-09-09 14:30 ` Chanwoo Choi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox