The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH V2] vfio/pds: replace bitmap_free with vfree
@ 2025-09-13 15:31 Zilin Guan
  2025-09-15 16:28 ` Brett Creeley
  0 siblings, 1 reply; 2+ messages in thread
From: Zilin Guan @ 2025-09-13 15:31 UTC (permalink / raw)
  To: jgg
  Cc: yishaih, shameerali.kolothum.thodi, kevin.tian, brett.creeley,
	alex.williamson, kvm, linux-kernel, jianhao.xu, Zilin Guan

host_seq_bmp is allocated with vzalloc but is currently freed with
bitmap_free, which uses kfree internally. This mismach prevents the
resource from being released properly and may result in memory leaks
or other issues.

Fix this by freeing host_seq_bmp with vfree to match the vzalloc
allocation.

Fixes: f232836a9152 ("vfio/pds: Add support for dirty page tracking")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---

Changes in v2:
- Fix the incorrect description in the commit log.
- Add "Fixes" tag accordingly.

 drivers/vfio/pci/pds/dirty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vfio/pci/pds/dirty.c b/drivers/vfio/pci/pds/dirty.c
index c51f5e4c3dd6..481992142f79 100644
--- a/drivers/vfio/pci/pds/dirty.c
+++ b/drivers/vfio/pci/pds/dirty.c
@@ -82,7 +82,7 @@ static int pds_vfio_dirty_alloc_bitmaps(struct pds_vfio_region *region,
 
 	host_ack_bmp = vzalloc(bytes);
 	if (!host_ack_bmp) {
-		bitmap_free(host_seq_bmp);
+		vfree(host_seq_bmp);
 		return -ENOMEM;
 	}
 
-- 
2.34.1


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

* Re: [PATCH V2] vfio/pds: replace bitmap_free with vfree
  2025-09-13 15:31 [PATCH V2] vfio/pds: replace bitmap_free with vfree Zilin Guan
@ 2025-09-15 16:28 ` Brett Creeley
  0 siblings, 0 replies; 2+ messages in thread
From: Brett Creeley @ 2025-09-15 16:28 UTC (permalink / raw)
  To: Zilin Guan, jgg
  Cc: yishaih, shameerali.kolothum.thodi, kevin.tian, brett.creeley,
	alex.williamson, kvm, linux-kernel, jianhao.xu



On 9/13/2025 8:31 AM, Zilin Guan wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
> 
> 
> host_seq_bmp is allocated with vzalloc but is currently freed with
> bitmap_free, which uses kfree internally. This mismach prevents the
> resource from being released properly and may result in memory leaks
> or other issues.
> 
> Fix this by freeing host_seq_bmp with vfree to match the vzalloc
> allocation.
> 
> Fixes: f232836a9152 ("vfio/pds: Add support for dirty page tracking")
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
> 
> Changes in v2:
> - Fix the incorrect description in the commit log.
> - Add "Fixes" tag accordingly.
> 
>   drivers/vfio/pci/pds/dirty.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/pci/pds/dirty.c b/drivers/vfio/pci/pds/dirty.c
> index c51f5e4c3dd6..481992142f79 100644
> --- a/drivers/vfio/pci/pds/dirty.c
> +++ b/drivers/vfio/pci/pds/dirty.c
> @@ -82,7 +82,7 @@ static int pds_vfio_dirty_alloc_bitmaps(struct pds_vfio_region *region,
> 
>          host_ack_bmp = vzalloc(bytes);
>          if (!host_ack_bmp) {
> -               bitmap_free(host_seq_bmp);
> +               vfree(host_seq_bmp);

Thanks for fixing this. I must have missed this from when the bitmap was 
reworked.

Reviewed-by: Brett Creeley <brett.creeley@amd.com>

>                  return -ENOMEM;
>          }
> 
> --
> 2.34.1
> 

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

end of thread, other threads:[~2025-09-15 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-13 15:31 [PATCH V2] vfio/pds: replace bitmap_free with vfree Zilin Guan
2025-09-15 16:28 ` Brett Creeley

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