> -----Original Message-----
> From: Zhang, RobinX <robinx.zh...@intel.com>
> Sent: Friday, June 18, 2021 2:39 PM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.x...@intel.com>; Guo, Junfeng
> <junfeng....@intel.com>; Yang, SteveX <stevex.y...@intel.com>; Zhang,
> RobinX <robinx.zh...@intel.com>; sta...@dpdk.org; Pau, Christopher
> <christopher....@intel.com>
> Subject: [PATCH 13/14] net/i40e/base: fix potentially uninitialized variables 
> in
> NVM code

Seems there're 2 fixes in the patch, please split them.

> 
> The status of i40e_read_nvm_word is not checked, so variables set from this
> function could be used uninitialized. In this case, preserve the existing flow
> that does not block initialization by initializing these values from the 
> start.
> 
> The variable checksum from i40e_calc_nvm_checksum is used before return
> value is checked. Fix this logic.
> 
> Fixes: 8d6c51fcd24b ("i40e/base: get OEM version")
> Fixes: 2db70574247b ("net/i40e/base: limit PF/VF specific code to that driver
> only")
> Fixes: 8db9e2a1b232 ("i40e: base driver")
> Fixes: 3ed6c3246f43 ("i40e/base: handle AQ timeout when releasing NVM")
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Christopher Pau <christopher....@intel.com>
> Signed-off-by: Robin Zhang <robinx.zh...@intel.com>
> ---
>  drivers/net/i40e/base/i40e_adminq.c | 6 ++++--
>  drivers/net/i40e/base/i40e_nvm.c    | 5 +++--
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/i40e/base/i40e_adminq.c
> b/drivers/net/i40e/base/i40e_adminq.c
> index eafacbdbec..d27ccde29a 100644
> --- a/drivers/net/i40e/base/i40e_adminq.c
> +++ b/drivers/net/i40e/base/i40e_adminq.c
> @@ -648,8 +648,10 @@ enum i40e_status_code i40e_init_adminq(struct
> i40e_hw *hw)  {
>       struct i40e_adminq_info *aq = &hw->aq;
>       enum i40e_status_code ret_code;
> -     u16 cfg_ptr, oem_hi, oem_lo;
> -     u16 eetrack_lo, eetrack_hi;
> +     u16 oem_hi = 0, oem_lo = 0;
> +     u16 eetrack_hi = 0;
> +     u16 eetrack_lo = 0;
> +     u16 cfg_ptr = 0;
>       int retry = 0;
> 
>       /* verify input for valid configuration */ diff --git
> a/drivers/net/i40e/base/i40e_nvm.c b/drivers/net/i40e/base/i40e_nvm.c
> index 67e58cc195..f385042601 100644
> --- a/drivers/net/i40e/base/i40e_nvm.c
> +++ b/drivers/net/i40e/base/i40e_nvm.c
> @@ -755,10 +755,11 @@ enum i40e_status_code
> i40e_update_nvm_checksum(struct i40e_hw *hw)
>       DEBUGFUNC("i40e_update_nvm_checksum");
> 
>       ret_code = i40e_calc_nvm_checksum(hw, &checksum);
> -     le_sum = CPU_TO_LE16(checksum);
> -     if (ret_code == I40E_SUCCESS)
> +     if (ret_code == I40E_SUCCESS) {
> +             le_sum = CPU_TO_LE16(checksum);
>               ret_code = i40e_write_nvm_aq(hw, 0x00,
> I40E_SR_SW_CHECKSUM_WORD,
>                                            1, &le_sum, true);
> +     }
> 
>       return ret_code;
>  }
> --
> 2.25.1

Reply via email to