Commit c0c643e1 authored by Mustafa Ismail's avatar Mustafa Ismail Committed by Doug Ledford

RDMA/i40iw: Fix device initialization error path

Some error paths in i40iw_initialize_dev are doing
additional and unnecessary work before exiting.
Correctly free resources allocated prior to error
and return with correct status code.
Signed-off-by: default avatarMustafa Ismail <mustafa.ismail@intelcom>
Signed-off-by: default avatarHenry Orosco <henry.orosco@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent b117f479
...@@ -1319,13 +1319,13 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev, ...@@ -1319,13 +1319,13 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev,
status = i40iw_obj_aligned_mem(iwdev, &mem, I40IW_QUERY_FPM_BUF_SIZE, status = i40iw_obj_aligned_mem(iwdev, &mem, I40IW_QUERY_FPM_BUF_SIZE,
I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK); I40IW_FPM_QUERY_BUF_ALIGNMENT_MASK);
if (status) if (status)
goto exit; goto error;
info.fpm_query_buf_pa = mem.pa; info.fpm_query_buf_pa = mem.pa;
info.fpm_query_buf = mem.va; info.fpm_query_buf = mem.va;
status = i40iw_obj_aligned_mem(iwdev, &mem, I40IW_COMMIT_FPM_BUF_SIZE, status = i40iw_obj_aligned_mem(iwdev, &mem, I40IW_COMMIT_FPM_BUF_SIZE,
I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK); I40IW_FPM_COMMIT_BUF_ALIGNMENT_MASK);
if (status) if (status)
goto exit; goto error;
info.fpm_commit_buf_pa = mem.pa; info.fpm_commit_buf_pa = mem.pa;
info.fpm_commit_buf = mem.va; info.fpm_commit_buf = mem.va;
info.hmc_fn_id = ldev->fid; info.hmc_fn_id = ldev->fid;
...@@ -1347,11 +1347,9 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev, ...@@ -1347,11 +1347,9 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev,
info.exception_lan_queue = 1; info.exception_lan_queue = 1;
info.vchnl_send = i40iw_virtchnl_send; info.vchnl_send = i40iw_virtchnl_send;
status = i40iw_device_init(&iwdev->sc_dev, &info); status = i40iw_device_init(&iwdev->sc_dev, &info);
exit:
if (status) { if (status)
kfree(iwdev->hmc_info_mem); goto error;
iwdev->hmc_info_mem = NULL;
}
memset(&vsi_info, 0, sizeof(vsi_info)); memset(&vsi_info, 0, sizeof(vsi_info));
vsi_info.dev = &iwdev->sc_dev; vsi_info.dev = &iwdev->sc_dev;
vsi_info.back_vsi = (void *)iwdev; vsi_info.back_vsi = (void *)iwdev;
...@@ -1362,11 +1360,19 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev, ...@@ -1362,11 +1360,19 @@ static enum i40iw_status_code i40iw_initialize_dev(struct i40iw_device *iwdev,
memset(&stats_info, 0, sizeof(stats_info)); memset(&stats_info, 0, sizeof(stats_info));
stats_info.fcn_id = ldev->fid; stats_info.fcn_id = ldev->fid;
stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL); stats_info.pestat = kzalloc(sizeof(*stats_info.pestat), GFP_KERNEL);
if (!stats_info.pestat) {
status = I40IW_ERR_NO_MEMORY;
goto error;
}
stats_info.stats_initialize = true; stats_info.stats_initialize = true;
if (stats_info.pestat) if (stats_info.pestat)
i40iw_vsi_stats_init(&iwdev->vsi, &stats_info); i40iw_vsi_stats_init(&iwdev->vsi, &stats_info);
} }
return status; return status;
error:
kfree(iwdev->hmc_info_mem);
iwdev->hmc_info_mem = NULL;
return status;
} }
/** /**
......
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