[PATCH] s390/pci: remove custom and misleading bitmap_vzalloc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This commit effectively reverts commit c1ae1c59c8c6 ("s390/pci: fix
iommu bitmap allocation") and applies a simpler fix instead. Commit
c1ae1c59c8c6 introduced a custom bitmap_vzalloc() function that included
unnecessary and misleading overflow handling.

This fix is only relevant for the current v6.6 and stable backports. It
will be superseded by the upcoming conversion to use the common
code DMA API on s390 (pending in linux-next [2]), which eliminates
arch/s390/pci/pci_dma.c entirely and, therefore, addresses the original
problem in another way.

Instead of relying on a custom bitmap_vzalloc() function, this change goes
back to straightforward allocation using vzalloc() with the appropriate
size calculated using the BITS_TO_LONGS() macro.

Link: https://lore.kernel.org/all/CAHk-=wgTUz1bdY6zvsN4ED0arCLE8Sb==1GH8d0sjm5bu7zesQ@xxxxxxxxxxxxxx/
Link: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=next-20231020&id=c76c067e488c
Cc: stable@xxxxxxxxxxxxxxx
Fixes: c1ae1c59c8c6 ("s390/pci: fix iommu bitmap allocation")
Suggested-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx>
---
 arch/s390/pci/pci_dma.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/s390/pci/pci_dma.c b/arch/s390/pci/pci_dma.c
index 99209085c75b..1b4b123d79aa 100644
--- a/arch/s390/pci/pci_dma.c
+++ b/arch/s390/pci/pci_dma.c
@@ -565,17 +565,6 @@ static void s390_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
 	}
 }
 
-static unsigned long *bitmap_vzalloc(size_t bits, gfp_t flags)
-{
-	size_t n = BITS_TO_LONGS(bits);
-	size_t bytes;
-
-	if (unlikely(check_mul_overflow(n, sizeof(unsigned long), &bytes)))
-		return NULL;
-
-	return vzalloc(bytes);
-}
-	
 int zpci_dma_init_device(struct zpci_dev *zdev)
 {
 	u8 status;
@@ -615,13 +604,15 @@ int zpci_dma_init_device(struct zpci_dev *zdev)
 				zdev->end_dma - zdev->start_dma + 1);
 	zdev->end_dma = zdev->start_dma + zdev->iommu_size - 1;
 	zdev->iommu_pages = zdev->iommu_size >> PAGE_SHIFT;
-	zdev->iommu_bitmap = bitmap_vzalloc(zdev->iommu_pages, GFP_KERNEL);
+	zdev->iommu_bitmap = vzalloc(BITS_TO_LONGS(zdev->iommu_pages) *
+				     sizeof(unsigned long));
 	if (!zdev->iommu_bitmap) {
 		rc = -ENOMEM;
 		goto free_dma_table;
 	}
 	if (!s390_iommu_strict) {
-		zdev->lazy_bitmap = bitmap_vzalloc(zdev->iommu_pages, GFP_KERNEL);
+		zdev->lazy_bitmap = vzalloc(BITS_TO_LONGS(zdev->iommu_pages) *
+					    sizeof(unsigned long));
 		if (!zdev->lazy_bitmap) {
 			rc = -ENOMEM;
 			goto free_bitmap;
-- 
2.39.2




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux