i40e: fix uninitialized variable in i40e_set_vsi_promisc
Subsystems (3)
PATCH 1/1 i40e: fix uninitialized variable in i40e_set_vsi_promisc
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function ?i40e_set_vsi_promisc?:drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:1176:14: error: ?aq_ret? may be used uninitialized in this function [-Werror=maybe-uninitialized]
i40e_status aq_ret;
In case the code inside the if statement and the for loop does not get executed aq_ret will be uninitialized when the variable gets returned at the end of the function.
--- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +1 -1
@@ -1173,7 +1173,7 @@ i40e_set_vsi_promisc(struct i40e_vf *vf, u16 seid, bool multi_enable, {struct i40e_pf *pf = vf->pf;struct i40e_hw *hw = &pf->hw; -i40e_status aq_ret; +i40e_status aq_ret =0 ;int i;/* No VLAN to set promisc on, set on VSI */
Signature · 1 line
2.26.2
Jakub Kicinski
maintainerQuoted 3 lines · On Wed, 12 Aug 2020 16:39:50 +0200 Stefan Assmann wrote:
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function ?i40e_set_vsi_promisc?:drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:1176:14: error: ?aq_ret? may be used uninitialized in this function [-Werror=maybe-uninitialized]
i40e_statusaq_ret;
What's your compiler? I don't see it on GCC 10.1.
Quoted 3 lines
In case the code inside the if statement and the for loop does not get executed
aq_retwill be uninitialized when the variable gets returned at the end of the function.
I think it'd be a better fix to make num_vlans unsigned.
Quoted 6 lines · Jakub Kicinski
Quoted 3 lines · On Wed, 12 Aug 2020 16:39:50 +0200 Stefan Assmann wrote:
drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c: In function ?i40e_set_vsi_promisc?:drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c:1176:14: error: ?aq_ret? may be used uninitialized in this function [-Werror=maybe-uninitialized]
i40e_statusaq_ret;What's your compiler? I don't see it on GCC 10.1.
gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)
Quoted 5 lines
Quoted 3 lines
In case the code inside the if statement and the for loop does not get executed
aq_retwill be uninitialized when the variable gets returned at the end of the function.I think it'd be a better fix to make
num_vlansunsigned.
Agreed, I'll send a v2 patch later.
Thanks for the review Jakub!
Stefan