* [PATCH] vfio/pds: replace bitmap_free with vfree
@ 2025-09-12 15:04 Zilin Guan
2025-09-12 16:55 ` Markus Elfring
2025-09-13 8:02 ` Alex Williamson
0 siblings, 2 replies; 3+ messages in thread
From: Zilin Guan @ 2025-09-12 15:04 UTC (permalink / raw)
To: brett.creeley
Cc: jgg, yishaih, shameerali.kolothum.thodi, kevin.tian,
alex.williamson, kvm, linux-kernel, jianhao.xu, Zilin Guan
host_ack_bmp is allocated with vzalloc but is currently freed via
bitmap_free (which ends up using kfree). This is incorrect as
allocation and deallocation functions should be paired.
Using mismatched alloc/free may lead to undefined behavior, memory leaks,
or system instability.
This patch fixes the mismatch by freeing host_ack_bmp with vfree to
match the vzalloc allocation.
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
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 [flat|nested] 3+ messages in thread
* Re: [PATCH] vfio/pds: replace bitmap_free with vfree
2025-09-12 15:04 [PATCH] vfio/pds: replace bitmap_free with vfree Zilin Guan
@ 2025-09-12 16:55 ` Markus Elfring
2025-09-13 8:02 ` Alex Williamson
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2025-09-12 16:55 UTC (permalink / raw)
To: Zilin Guan, kvm
Cc: LKML, Alex Williamson, Brett Creeley, Jason Gunthorpe,
Jianhao Xu, Kevin Tian, Shameer Kolothum, Yishai Hadas
…
> This patch fixes the mismatch by …
* See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n94
* Would it be helpful to append parentheses to function names?
* How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vfio/pds: replace bitmap_free with vfree
2025-09-12 15:04 [PATCH] vfio/pds: replace bitmap_free with vfree Zilin Guan
2025-09-12 16:55 ` Markus Elfring
@ 2025-09-13 8:02 ` Alex Williamson
1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2025-09-13 8:02 UTC (permalink / raw)
To: Zilin Guan
Cc: brett.creeley, jgg, yishaih, shameerali.kolothum.thodi,
kevin.tian, kvm, linux-kernel, jianhao.xu
On Fri, 12 Sep 2025 15:04:18 +0000
Zilin Guan <zilin@seu.edu.cn> wrote:
> host_ack_bmp is allocated with vzalloc but is currently freed via
> bitmap_free (which ends up using kfree). This is incorrect as
> allocation and deallocation functions should be paired.
This patch is fixing the freeing of host_seq_bmp, not host_ack_bmp.
Both are allocated with vzalloc(). The same logic applies but the
commit log is incorrect.
> Using mismatched alloc/free may lead to undefined behavior, memory leaks,
> or system instability.
>
> This patch fixes the mismatch by freeing host_ack_bmp with vfree to
> match the vzalloc allocation.
>
Fixes: f232836a9152 ("vfio/pds: Add support for dirty page tracking")
Thanks,
Alex
> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
> 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;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-13 8:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-12 15:04 [PATCH] vfio/pds: replace bitmap_free with vfree Zilin Guan
2025-09-12 16:55 ` Markus Elfring
2025-09-13 8:02 ` Alex Williamson
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®