mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] RDMA/core: fix memory alloc/free for pfn_list
@ 2025-08-10 17:51 Akhilesh Patil
  2025-08-13 11:02 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Akhilesh Patil @ 2025-08-10 17:51 UTC (permalink / raw)
  To: jgg, leon, akhilesh, michaelgur, ohartoov, shayd, dskmtsd, hch
  Cc: linux-rdma, linux-kernel, akhileshpatilvnit, skhan

Ensure memory allocated for umem_odp->map->pfn_list using kvcalloc()
is freed using corresponding kvfree() to avoid potential memory
corruption. Match memory allocation and free routines kvcalloc -> kvfree

Fixes: 259e9bd07c57 ("RDMA/core: Avoid hmm_dma_map_alloc() for virtual DMA devices")
Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
---
 drivers/infiniband/core/umem_odp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
index b1c44ec1a3f3..572a91a62a7b 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -115,7 +115,7 @@ static int ib_init_umem_odp(struct ib_umem_odp *umem_odp,
 
 out_free_map:
 	if (ib_uses_virt_dma(dev))
-		kfree(map->pfn_list);
+		kvfree(map->pfn_list);
 	else
 		hmm_dma_map_free(dev->dma_device, map);
 	return ret;
@@ -287,7 +287,7 @@ static void ib_umem_odp_free(struct ib_umem_odp *umem_odp)
 	mutex_unlock(&umem_odp->umem_mutex);
 	mmu_interval_notifier_remove(&umem_odp->notifier);
 	if (ib_uses_virt_dma(dev))
-		kfree(umem_odp->map.pfn_list);
+		kvfree(umem_odp->map.pfn_list);
 	else
 		hmm_dma_map_free(dev->dma_device, &umem_odp->map);
 }
-- 
2.34.1


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

* Re: [PATCH] RDMA/core: fix memory alloc/free for pfn_list
  2025-08-10 17:51 [PATCH] RDMA/core: fix memory alloc/free for pfn_list Akhilesh Patil
@ 2025-08-13 11:02 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2025-08-13 11:02 UTC (permalink / raw)
  To: jgg, michaelgur, ohartoov, shayd, dskmtsd, hch, Akhilesh Patil
  Cc: linux-rdma, linux-kernel, akhileshpatilvnit, skhan


On Sun, 10 Aug 2025 23:21:58 +0530, Akhilesh Patil wrote:
> Ensure memory allocated for umem_odp->map->pfn_list using kvcalloc()
> is freed using corresponding kvfree() to avoid potential memory
> corruption. Match memory allocation and free routines kvcalloc -> kvfree
> 
> 

Applied, thanks!

[1/1] RDMA/core: fix memory alloc/free for pfn_list
      https://git.kernel.org/rdma/rdma/c/111aea0464c20f

Best regards,
-- 
Leon Romanovsky <leon@kernel.org>


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

end of thread, other threads:[~2025-08-13 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-10 17:51 [PATCH] RDMA/core: fix memory alloc/free for pfn_list Akhilesh Patil
2025-08-13 11:02 ` Leon Romanovsky

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®