Skip to contentSkip to conversation

iommu/dma: Use kvcalloc() instead of kvzalloc()

PATCH Applied Gustavo A. R. Silva 4 participants 4 messages Sep 28, 2021 – Oct 27, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/dma: Use kvcalloc() instead of kvzalloc()

Use 2-factor argument form kvcalloc() instead of kvzalloc().

---
 drivers/iommu/dma-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
index 896bea04c347..18c6edbe5fbf 100644
@@ -616,7 +616,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
 	if (!order_mask)
 		return NULL;
 
-	pages = kvzalloc(count * sizeof(*pages), GFP_KERNEL);
+	pages = kvcalloc(count, sizeof(*pages), GFP_KERNEL);
 	if (!pages)
 		return NULL;
 
Signature · 1 line
2.27.0
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 1 line · Gustavo A. R. Silva

Use 2-factor argument form kvcalloc() instead of kvzalloc().

If we have a thing for that now, then sure, why not. FWIW this can't ever overflow due to where "count" comes from, but it has no reason to be special.

Quoted 20 lines
---
  drivers/iommu/dma-iommu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +1 -1
index 896bea04c347..18c6edbe5fbf 100644
@@ -616,7 +616,7 @@ static struct page **__iommu_dma_alloc_pages(struct device *dev,
  	if (!order_mask)
  		return NULL;
 
-	pages = kvzalloc(count * sizeof(*pages), GFP_KERNEL);
+	pages = kvcalloc(count, sizeof(*pages), GFP_KERNEL);
  	if (!pages)
  		return NULL;
 
maintainer Applied
#3 lore raw
In reply to Gustavo A. R. Silva
Quoted 7 lines · Gustavo A. R. Silva

Use 2-factor argument form kvcalloc() instead of kvzalloc().

---
 drivers/iommu/dma-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu