mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vfio/platform: Remove unnecessary free in vfio_set_trigger
@ 2024-01-12  6:41 Kunwu Chan
  2024-01-12 15:34 ` Alex Williamson
  0 siblings, 1 reply; 3+ messages in thread
From: Kunwu Chan @ 2024-01-12  6:41 UTC (permalink / raw)
  To: eric.auger, alex.williamson
  Cc: a.motakis, b.reynal, kvm, linux-kernel, Kunwu Chan

commit 57f972e2b341 ("vfio/platform: trigger an interrupt via eventfd")
add 'name' as member for vfio_platform_irq,it's initialed by kasprintf,
so there is no need to free it before initializing.

Fixes: 57f972e2b341 ("vfio/platform: trigger an interrupt via eventfd")
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 drivers/vfio/platform/vfio_platform_irq.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
index 61a1bfb68ac7..5e3fd1926366 100644
--- a/drivers/vfio/platform/vfio_platform_irq.c
+++ b/drivers/vfio/platform/vfio_platform_irq.c
@@ -179,7 +179,6 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,
 	if (irq->trigger) {
 		irq_clear_status_flags(irq->hwirq, IRQ_NOAUTOEN);
 		free_irq(irq->hwirq, irq);
-		kfree(irq->name);
 		eventfd_ctx_put(irq->trigger);
 		irq->trigger = NULL;
 	}
-- 
2.39.2


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

* Re: [PATCH] vfio/platform: Remove unnecessary free in vfio_set_trigger
  2024-01-12  6:41 [PATCH] vfio/platform: Remove unnecessary free in vfio_set_trigger Kunwu Chan
@ 2024-01-12 15:34 ` Alex Williamson
  2024-01-15  6:08   ` Kunwu Chan
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Williamson @ 2024-01-12 15:34 UTC (permalink / raw)
  To: Kunwu Chan; +Cc: eric.auger, a.motakis, b.reynal, kvm, linux-kernel

On Fri, 12 Jan 2024 14:41:07 +0800
Kunwu Chan <chentao@kylinos.cn> wrote:

> commit 57f972e2b341 ("vfio/platform: trigger an interrupt via eventfd")
> add 'name' as member for vfio_platform_irq,it's initialed by kasprintf,
> so there is no need to free it before initializing.

What?!  Just look at the call path where vfio_set_trigger() is called
with a valid fd and existing trigger.  This change would leak irq->name
as it's reallocated via kasprintf().  Thanks,

Alex
 
> Fixes: 57f972e2b341 ("vfio/platform: trigger an interrupt via eventfd")
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
>  drivers/vfio/platform/vfio_platform_irq.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
> index 61a1bfb68ac7..5e3fd1926366 100644
> --- a/drivers/vfio/platform/vfio_platform_irq.c
> +++ b/drivers/vfio/platform/vfio_platform_irq.c
> @@ -179,7 +179,6 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,
>  	if (irq->trigger) {
>  		irq_clear_status_flags(irq->hwirq, IRQ_NOAUTOEN);
>  		free_irq(irq->hwirq, irq);
> -		kfree(irq->name);
>  		eventfd_ctx_put(irq->trigger);
>  		irq->trigger = NULL;
>  	}


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

* Re: [PATCH] vfio/platform: Remove unnecessary free in vfio_set_trigger
  2024-01-12 15:34 ` Alex Williamson
@ 2024-01-15  6:08   ` Kunwu Chan
  0 siblings, 0 replies; 3+ messages in thread
From: Kunwu Chan @ 2024-01-15  6:08 UTC (permalink / raw)
  To: Alex Williamson; +Cc: eric.auger, a.motakis, b.reynal, kvm, linux-kernel

On 2024/1/12 23:34, Alex Williamson wrote:
> On Fri, 12 Jan 2024 14:41:07 +0800
> Kunwu Chan <chentao@kylinos.cn> wrote:
> 
>> commit 57f972e2b341 ("vfio/platform: trigger an interrupt via eventfd")
>> add 'name' as member for vfio_platform_irq,it's initialed by kasprintf,
>> so there is no need to free it before initializing.
> 
> What?!  Just look at the call path where vfio_set_trigger() is called
> with a valid fd and existing trigger.  This change would leak irq->name
> as it's reallocated via kasprintf().  Thanks,
> 
> Alex
>   
>> Fixes: 57f972e2b341 ("vfio/platform: trigger an interrupt via eventfd")
>> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
>> ---
>>   drivers/vfio/platform/vfio_platform_irq.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c
>> index 61a1bfb68ac7..5e3fd1926366 100644
>> --- a/drivers/vfio/platform/vfio_platform_irq.c
>> +++ b/drivers/vfio/platform/vfio_platform_irq.c
>> @@ -179,7 +179,6 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index,
>>   	if (irq->trigger) {
>>   		irq_clear_status_flags(irq->hwirq, IRQ_NOAUTOEN);
>>   		free_irq(irq->hwirq, irq);
>> -		kfree(irq->name);
>>   		eventfd_ctx_put(irq->trigger);
>>   		irq->trigger = NULL;
>>   	}
> 
Thanks for your reply.

It's my bad.I misunderstood. Sorry to bother you.
-- 
Thanks,
   Kunwu


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

end of thread, other threads:[~2024-01-15  6:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-12  6:41 [PATCH] vfio/platform: Remove unnecessary free in vfio_set_trigger Kunwu Chan
2024-01-12 15:34 ` Alex Williamson
2024-01-15  6:08   ` Kunwu Chan

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

all inboxes | Powered by JetHome®