Netdev List
 help / color / mirror / Atom feed
* [PATCH] ice: parser: use array_size() for table allocation
@ 2026-07-16  2:51 Weimin Xiong
  2026-07-20 15:05 ` [Intel-wired-lan] " Alexander Lobakin
  0 siblings, 1 reply; 3+ messages in thread
From: Weimin Xiong @ 2026-07-16  2:51 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel
  Cc: intel-wired-lan, netdev, linux-kernel, Andrew Lunn,
	David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Weimin Xiong

Use array_size() when calculating the parser table allocation size so an
overflow in the firmware-provided item dimensions is detected before
allocation. Include the overflow helpers explicitly instead of relying on
an indirect include.

Signed-off-by: Weimin Xiong <xiongwm2026@163.com>
---
diff --git a/drivers/net/ethernet/intel/ice/ice_parser.c b/drivers/net/ethernet/intel/ice/ice_parser.c
index f8e69630f..c109d3c32 100644
--- a/drivers/net/ethernet/intel/ice/ice_parser.c
+++ b/drivers/net/ethernet/intel/ice/ice_parser.c
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright (C) 2024 Intel Corporation */
 
+#include <linux/overflow.h>
+
 #include "ice_common.h"
 
 struct ice_pkg_sect_hdr {
@@ -102,7 +104,7 @@ ice_parser_create_table(struct ice_hw *hw, u32 sect_type,
 	if (!seg)
 		return ERR_PTR(-EINVAL);
 
-	table = kzalloc(item_size * length, GFP_KERNEL);
+	table = kzalloc(array_size(item_size, length), GFP_KERNEL);
 	if (!table)
 		return ERR_PTR(-ENOMEM);
 


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

end of thread, other threads:[~2026-07-21  1:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  2:51 [PATCH] ice: parser: use array_size() for table allocation Weimin Xiong
2026-07-20 15:05 ` [Intel-wired-lan] " Alexander Lobakin
2026-07-21  1:57   ` [PATCH v2] ice: parser: use kcalloc " Weimin Xiong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox