Skip to content

Commit 330aa3b

Browse files
mszapargregkh
authored andcommitted
i40e: Memory leak in i40e_config_iwarp_qvlist
[ Upstream commit 0b63644 ] Added freeing the old allocation of vf->qvlist_info in function i40e_config_iwarp_qvlist before overwriting it with the new allocation. Fixes: e3219ce ("i40e: Add support for client interface for IWARP driver") Signed-off-by: Martyna Szapar <martyna.szapar@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 71d7816 commit 330aa3b

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
441441
u32 v_idx, i, reg_idx, reg;
442442
u32 next_q_idx, next_q_type;
443443
u32 msix_vf, size;
444+
int ret = 0;
444445

445446
msix_vf = pf->hw.func_caps.num_msix_vectors_vf;
446447

@@ -449,16 +450,19 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
449450
"Incorrect number of iwarp vectors %u. Maximum %u allowed.\n",
450451
qvlist_info->num_vectors,
451452
msix_vf);
452-
goto err;
453+
ret = -EINVAL;
454+
goto err_out;
453455
}
454456

455457
size = sizeof(struct virtchnl_iwarp_qvlist_info) +
456458
(sizeof(struct virtchnl_iwarp_qv_info) *
457459
(qvlist_info->num_vectors - 1));
460+
kfree(vf->qvlist_info);
458461
vf->qvlist_info = kzalloc(size, GFP_KERNEL);
459-
if (!vf->qvlist_info)
460-
return -ENOMEM;
461-
462+
if (!vf->qvlist_info) {
463+
ret = -ENOMEM;
464+
goto err_out;
465+
}
462466
vf->qvlist_info->num_vectors = qvlist_info->num_vectors;
463467

464468
msix_vf = pf->hw.func_caps.num_msix_vectors_vf;
@@ -469,8 +473,10 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
469473
v_idx = qv_info->v_idx;
470474

471475
/* Validate vector id belongs to this vf */
472-
if (!i40e_vc_isvalid_vector_id(vf, v_idx))
473-
goto err;
476+
if (!i40e_vc_isvalid_vector_id(vf, v_idx)) {
477+
ret = -EINVAL;
478+
goto err_free;
479+
}
474480

475481
vf->qvlist_info->qv_info[i] = *qv_info;
476482

@@ -512,10 +518,11 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
512518
}
513519

514520
return 0;
515-
err:
521+
err_free:
516522
kfree(vf->qvlist_info);
517523
vf->qvlist_info = NULL;
518-
return -EINVAL;
524+
err_out:
525+
return ret;
519526
}
520527

521528
/**

0 commit comments

Comments
 (0)