On Tue, Aug 01, 2023 at 01:19:23PM +0200, Przemek Kitszel wrote:
quoted hunk ↗ jump to hunk
Use DECLARE_FLEX() macro for 1-elem flex array members of ice_switch.c
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
drivers/net/ethernet/intel/ice/ice_switch.c | 53 +++++----------------
1 file changed, 12 insertions(+), 41 deletions(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index a7afb612fe32..41679cb6b548 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -1812,15 +1812,11 @@ ice_aq_alloc_free_vsi_list(struct ice_hw *hw, u16 *vsi_list_id,
enum ice_sw_lkup_type lkup_type,
enum ice_adminq_opc opc)
{
- struct ice_aqc_alloc_free_res_elem *sw_buf;
+ DECLARE_FLEX(struct ice_aqc_alloc_free_res_elem *, sw_buf, elem, 1);
+ u16 buf_len = struct_size(sw_buf, elem, 1);
With the macro I suggested, I think this line can become:
u16 buf_len = __builtin_object_size(sw_buf, 1);
but either is fine. (N.B. the "1" here is a bitfield, not the "1" size
above).
-Kees
--
Kees Cook