Commit 330aa3b4 authored by Martyna Szapar's avatar Martyna Szapar Committed by Greg Kroah-Hartman

i40e: Memory leak in i40e_config_iwarp_qvlist

[ Upstream commit 0b636446 ]

Added freeing the old allocation of vf->qvlist_info in function
i40e_config_iwarp_qvlist before overwriting it with
the new allocation.

Fixes: e3219ce6 ("i40e: Add support for client interface for IWARP driver")
Signed-off-by: default avatarMartyna Szapar <martyna.szapar@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 71d78161
...@@ -441,6 +441,7 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf, ...@@ -441,6 +441,7 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
u32 v_idx, i, reg_idx, reg; u32 v_idx, i, reg_idx, reg;
u32 next_q_idx, next_q_type; u32 next_q_idx, next_q_type;
u32 msix_vf, size; u32 msix_vf, size;
int ret = 0;
msix_vf = pf->hw.func_caps.num_msix_vectors_vf; msix_vf = pf->hw.func_caps.num_msix_vectors_vf;
...@@ -449,16 +450,19 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf, ...@@ -449,16 +450,19 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
"Incorrect number of iwarp vectors %u. Maximum %u allowed.\n", "Incorrect number of iwarp vectors %u. Maximum %u allowed.\n",
qvlist_info->num_vectors, qvlist_info->num_vectors,
msix_vf); msix_vf);
goto err; ret = -EINVAL;
goto err_out;
} }
size = sizeof(struct virtchnl_iwarp_qvlist_info) + size = sizeof(struct virtchnl_iwarp_qvlist_info) +
(sizeof(struct virtchnl_iwarp_qv_info) * (sizeof(struct virtchnl_iwarp_qv_info) *
(qvlist_info->num_vectors - 1)); (qvlist_info->num_vectors - 1));
kfree(vf->qvlist_info);
vf->qvlist_info = kzalloc(size, GFP_KERNEL); vf->qvlist_info = kzalloc(size, GFP_KERNEL);
if (!vf->qvlist_info) if (!vf->qvlist_info) {
return -ENOMEM; ret = -ENOMEM;
goto err_out;
}
vf->qvlist_info->num_vectors = qvlist_info->num_vectors; vf->qvlist_info->num_vectors = qvlist_info->num_vectors;
msix_vf = pf->hw.func_caps.num_msix_vectors_vf; msix_vf = pf->hw.func_caps.num_msix_vectors_vf;
...@@ -469,8 +473,10 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf, ...@@ -469,8 +473,10 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
v_idx = qv_info->v_idx; v_idx = qv_info->v_idx;
/* Validate vector id belongs to this vf */ /* Validate vector id belongs to this vf */
if (!i40e_vc_isvalid_vector_id(vf, v_idx)) if (!i40e_vc_isvalid_vector_id(vf, v_idx)) {
goto err; ret = -EINVAL;
goto err_free;
}
vf->qvlist_info->qv_info[i] = *qv_info; vf->qvlist_info->qv_info[i] = *qv_info;
...@@ -512,10 +518,11 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf, ...@@ -512,10 +518,11 @@ static int i40e_config_iwarp_qvlist(struct i40e_vf *vf,
} }
return 0; return 0;
err: err_free:
kfree(vf->qvlist_info); kfree(vf->qvlist_info);
vf->qvlist_info = NULL; vf->qvlist_info = NULL;
return -EINVAL; err_out:
return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment