ice: use flex_array_size where possible
authorBruce Allan <bruce.w.allan@intel.com>
Sat, 21 Nov 2020 00:39:36 +0000 (16:39 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 5 Feb 2021 19:44:42 +0000 (11:44 -0800)
Use the flex_array_size() helper with the recently added flexible array
members in structures.

Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_common.c
drivers/net/ethernet/intel/ice/ice_flex_pipe.c

index 6d7e7dd0ebe22d6126fb4e6d733a99d7a08e3e4d..607d33d05a0cee79ce773950a280b338fcd3680a 100644 (file)
@@ -1653,7 +1653,7 @@ ice_aq_alloc_free_res(struct ice_hw *hw, u16 num_entries,
        if (!buf)
                return ICE_ERR_PARAM;
 
-       if (buf_size < (num_entries * sizeof(buf->elem[0])))
+       if (buf_size < flex_array_size(buf, elem, num_entries))
                return ICE_ERR_PARAM;
 
        ice_fill_dflt_direct_cmd_desc(&desc, opc);
index f5e81b5553537ba5988abb64ee4715dc6b8391bb..cf5b717b92931b34d6871af1ab96aac610abb301 100644 (file)
@@ -1525,7 +1525,7 @@ ice_pkg_buf_reserve_section(struct ice_buf_build *bld, u16 count)
        bld->reserved_section_table_entries += count;
 
        data_end = le16_to_cpu(buf->data_end) +
-                  (count * sizeof(buf->section_entry[0]));
+               flex_array_size(buf, section_entry, count);
        buf->data_end = cpu_to_le16(data_end);
 
        return 0;