On 3/5/2024 5:17 AM, Simon Horman wrote:
 --- a/drivers/net/ethernet/intel/ice/ice_lib.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
>> @@ -3238,7 +3238,7 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 vsi_flags)
>>  {
>>      struct ice_vsi_cfg_params params = {};
>>      struct ice_coalesce_stored *coalesce;
>> -    int prev_num_q_vectors = 0;
>> +    int prev_num_q_vectors;
>>      struct ice_pf *pf;
>>      int ret;
>>  
>> @@ -3252,13 +3252,6 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 
>> vsi_flags)
>>      if (WARN_ON(vsi->type == ICE_VSI_VF && !vsi->vf))
>>              return -EINVAL;
>>  
>> -    coalesce = kcalloc(vsi->num_q_vectors,
>> -                       sizeof(struct ice_coalesce_stored), GFP_KERNEL);
>> -    if (!coalesce)
>> -            return -ENOMEM;
>> -
>> -    prev_num_q_vectors = ice_vsi_rebuild_get_coalesce(vsi, coalesce);
>> -
>>      ret = ice_vsi_realloc_stat_arrays(vsi);
>>      if (ret)
>>              goto err_vsi_cfg;
>> @@ -3268,6 +3261,13 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, u32 
>> vsi_flags)
>>      if (ret)
>>              goto err_vsi_cfg;
> 
> Hi Jesse,
> 
> the label above will result in a call to kfree(coalesce).
> However, coalesce is now uninitialised until the following line executes.

Thanks Simon, you're right! And it figures, The internal static analysis
runs caught this only after I sent the patch to the list.

One fix is to NULL the initialization of coalesce, which solves the
problem with a one-liner, but I'll look more today at whether I should
just move the label or something else.

Reply via email to