ice: Use struct_size() helper
Subsystems (3)
PATCH 1/1 ice: Use struct_size() helper
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes.
This code was detected with the help of Coccinelle and, audited and fixed manually.
Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
--- drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +1 -2
@@ -1121,8 +1121,7 @@ static enum ice_status ice_get_pkg_info(struct ice_hw *hw)u16 size;u32 i; - size =sizeof (*pkg_info) + (sizeof (pkg_info->pkg_info[0 ]) * - (ICE_PKG_CNT -1 )); + size =struct_size (pkg_info, pkg_info,ICE_PKG_CNT -1 ); pkg_info =kzalloc (size,GFP_KERNEL );if (!pkg_info)return ICE_ERR_NO_MEMORY ;
Signature · 1 line
2.27.0
Quoted 13 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Gustavo A. R. Silva
Sent: Friday, June 19, 2020 10:56 AM
To: Kirsher, Jeffrey T <[email protected]>; David S. Miller <[email protected]>; Jakub Kicinski <[email protected]>
Cc: netdev at vger.kernel.org; intel-wired-lan at lists.osuosl.org; linux- kernel at vger.kernel.org
Subject: [Intel-wired-lan] [PATCH][next] ice: Usestruct_size()helperMake use of the
struct_size()helper instead of an open-coded version in order to avoid any potential type mistakes.
Quoted 8 lines
This code was detected with the help of Coccinelle and, audited and fixed manually.
Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/net/ethernet/intel/ice/ice_flex_pipe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
This is already fixed in an in-process patch-set that converts one-element arrays to flexible-arrays that Jeff Kirsher has mentioned before and should be pushed shortly.
Quoted 24 lines
drivers/net/ethernet/intel/ice/ice_flex_pipe.c +1
-2@@ -1121,8 +1121,7 @@ static enum ice_status ice_get_pkg_info(struct ice_hw *hw) u16 size;u32 i; - size =sizeof (*pkg_info) + (sizeof (pkg_info->pkg_info[0 ]) * - (ICE_PKG_CNT -1 )); + size =struct_size (pkg_info, pkg_info,ICE_PKG_CNT -1 ); pkg_info =kzalloc (size,GFP_KERNEL );if (!pkg_info)return
ICE_ERR_NO_MEMORY;
--
2.27.0_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan