net/ice/base: fix memory allocation wrapper
authorDavid Marchand <david.marchand@redhat.com>
Thu, 6 May 2021 10:07:02 +0000 (12:07 +0200)
committerQi Zhang <qi.z.zhang@intel.com>
Mon, 10 May 2021 02:58:55 +0000 (04:58 +0200)
commit35f9cb006534018b6f69dce8f0d22684fe98e812
tree22dc6317133a6c21fdc1b2677b7b6fdaa10666ed
parent5d28b6605532a9a4e24884abb779afcecce9110b
net/ice/base: fix memory allocation wrapper

This is reported by our internal covscan:

1. dpdk-20.11/drivers/net/ice/base/ice_switch.c:4214: sign_extension:
Suspicious implicit sign extension: "s_rule_size" with type "u16" (16
bits, unsigned) is promoted in "num_unicast * s_rule_size" to type "int"
(32 bits, signed), then sign-extended to type "unsigned long" (64 bits,
unsigned).
If "num_unicast * s_rule_size" is greater than 0x7FFFFFFF, the upper bits
of the result will all be 1.

 #  4212|    s_rule_size = ICE_SW_RULE_RX_TX_ETH_HDR_SIZE;
 #  4213|    s_rule = (struct ice_aqc_sw_rules_elem *)
 #  4214|->  ice_calloc(hw, num_unicast, s_rule_size);
 #  4215|    if (!s_rule) {
 #  4216|    status = ICE_ERR_NO_MEMORY;

Even if this condition is not likely to happen, in any case, it is more
straightforward to rely on the existing rte_calloc.

Fixes: 5f0978e96220 ("net/ice/base: add OS specific implementation")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
drivers/net/ice/base/ice_osdep.h