All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: atlantic: Use kmalloc_array to prevent overflow of dynamic size calculation
@ 2025-09-30 11:19 Bhanu Seshu Kumar Valluri
  2025-09-30 11:24 ` Sahil Chandna
  0 siblings, 1 reply; 5+ messages in thread
From: Bhanu Seshu Kumar Valluri @ 2025-09-30 11:19 UTC (permalink / raw)
  To: epomozov, irusskikh, andrew+netdev, davem, edumazet, kuba, pabeni,
	richardcochran, bhanuseshukumar
  Cc: linux-kernel-mentees, skhan, david.hunter.linux

Use kmalloc_array to avoid potential overflow during dynamic size calculation
inside kmalloc.

Signed-off-by: Bhanu Seshu Kumar Valluri <bhanuseshukumar@gmail.com>
---
 Note: Patch is tested for compilation.
 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
index 5acb3e16b567..f445d449f80f 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
@@ -182,7 +182,7 @@ static unsigned int aq_ptp_skb_buf_len(struct ptp_skb_ring *ring)
 
 static int aq_ptp_skb_ring_init(struct ptp_skb_ring *ring, unsigned int size)
 {
-	struct sk_buff **buff = kmalloc(sizeof(*buff) * size, GFP_KERNEL);
+	struct sk_buff **buff = kmalloc_array(sizeof(*buff), size, GFP_KERNEL);
 
 	if (!buff)
 		return -ENOMEM;
-- 
2.34.1


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

end of thread, other threads:[~2025-09-30 13:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-30 11:19 [PATCH] net: atlantic: Use kmalloc_array to prevent overflow of dynamic size calculation Bhanu Seshu Kumar Valluri
2025-09-30 11:24 ` Sahil Chandna
2025-09-30 11:37   ` bhanuseshukumar
2025-09-30 12:17     ` Eric Dumazet
2025-09-30 13:12       ` Bhanu Seshu Kumar Valluri

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.