From: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
To: jgg@ziepe.ca, kevin.tian@intel.com, joro@8bytes.org,
will@kernel.org, robin.murphy@arm.com, praan@google.com,
baolu.lu@linux.intel.com, nicolinc@nvidia.com, jgg@nvidia.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
akhileshpatilvnit@gmail.com, skhan@linuxfoundation.org
Subject: [PATCH] iommufd: viommu: free memory allocated by kvcalloc() using kvfree()
Date: Sun, 10 Aug 2025 19:04:01 +0530 [thread overview]
Message-ID: <aJifyVV2PL6WGEs6@bhairav-test.ee.iitb.ac.in> (raw)
Use kvfree() instead of kfree() to free pages allocated by kvcalloc()
in iommufs_hw_queue_alloc_phys() to fix potential memory corruption.
Ensure the memory is properly freed, as kvcalloc may internally use
vmalloc or kmalloc depending on available memory in the system.
Fixes: 2238ddc2b056 ("iommufd/viommu: Add IOMMUFD_CMD_HW_QUEUE_ALLOC ioctl")
Signed-off-by: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
---
drivers/iommu/iommufd/viommu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/iommufd/viommu.c b/drivers/iommu/iommufd/viommu.c
index 2ca5809b238b..462b457ffd0c 100644
--- a/drivers/iommu/iommufd/viommu.c
+++ b/drivers/iommu/iommufd/viommu.c
@@ -339,7 +339,7 @@ iommufd_hw_queue_alloc_phys(struct iommu_hw_queue_alloc *cmd,
}
*base_pa = (page_to_pfn(pages[0]) << PAGE_SHIFT) + offset;
- kfree(pages);
+ kvfree(pages);
return access;
out_unpin:
@@ -349,7 +349,7 @@ iommufd_hw_queue_alloc_phys(struct iommu_hw_queue_alloc *cmd,
out_destroy:
iommufd_access_destroy_internal(viommu->ictx, access);
out_free:
- kfree(pages);
+ kvfree(pages);
return ERR_PTR(rc);
}
--
2.34.1
next reply other threads:[~2025-08-10 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 13:34 Akhilesh Patil [this message]
2025-08-10 17:53 ` Nicolin Chen
2025-08-15 10:06 ` Tian, Kevin
2025-08-15 10:45 ` Pranjal Shrivastava
2025-08-15 13:42 ` Markus Elfring
2025-08-15 14:15 ` Robin Murphy
2025-08-15 14:52 ` Markus Elfring
2025-08-18 14:14 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJifyVV2PL6WGEs6@bhairav-test.ee.iitb.ac.in \
--to=akhilesh@ee.iitb.ac.in \
--cc=akhileshpatilvnit@gmail.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=praan@google.com \
--cc=robin.murphy@arm.com \
--cc=skhan@linuxfoundation.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®