Skip to contentSkip to conversation

media: staging: ipu3: use vcalloc() instead of vzalloc() with multiply

PATCH New Hrushiraj Gandhi 1 participant 1 message Sep 1

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

PATCH 1/1 media: staging: ipu3: use vcalloc() instead of vzalloc() with multiply

mmu->l2pts is sized as IPU3_PT_PTES * sizeof(*mmu->l2pts) by hand. Use vcalloc() instead, which computes the size via the overflow-checked size_mul() so a large enough count fails the allocation cleanly instead of silently wrapping size_t into a too-small buffer.

No functional change.

---
 drivers/staging/media/ipu3/ipu3-mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu3/ipu3-mmu.c +1 -1
index b196a5815903..ab40502c06b8 100644
@@ -464,7 +464,7 @@ struct imgu_mmu_info *imgu_mmu_init(struct device *parent, void __iomem *base)
 	 * Allocate the array of L2PT CPU pointers, initialized to zero,
 	 * which means the dummy L2PT allocated above.
 	 */
-	mmu->l2pts = vzalloc(IPU3_PT_PTES * sizeof(*mmu->l2pts));
+	mmu->l2pts = vcalloc(IPU3_PT_PTES, sizeof(*mmu->l2pts));
 	if (!mmu->l2pts)
 		goto fail_l2pt;