Commit e2a438bd authored by Kangjie Lu's avatar Kangjie Lu Committed by Jason Gunthorpe

RDMA/i40iw: Handle workqueue allocation failure

alloc_ordered_workqueue may fail and return NULL.  The fix captures the
failure and handles it properly to avoid potential NULL pointer
dereferences.
Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Reviewed-by: default avatarShiraz, Saleem <shiraz.saleem@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 4ae27444
......@@ -552,7 +552,7 @@ enum i40iw_status_code i40iw_obj_aligned_mem(struct i40iw_device *iwdev,
void i40iw_request_reset(struct i40iw_device *iwdev);
void i40iw_destroy_rdma_device(struct i40iw_ib_device *iwibdev);
void i40iw_setup_cm_core(struct i40iw_device *iwdev);
int i40iw_setup_cm_core(struct i40iw_device *iwdev);
void i40iw_cleanup_cm_core(struct i40iw_cm_core *cm_core);
void i40iw_process_ceq(struct i40iw_device *, struct i40iw_ceq *iwceq);
void i40iw_process_aeq(struct i40iw_device *);
......
......@@ -3237,7 +3237,7 @@ void i40iw_receive_ilq(struct i40iw_sc_vsi *vsi, struct i40iw_puda_buf *rbuf)
* core
* @iwdev: iwarp device structure
*/
void i40iw_setup_cm_core(struct i40iw_device *iwdev)
int i40iw_setup_cm_core(struct i40iw_device *iwdev)
{
struct i40iw_cm_core *cm_core = &iwdev->cm_core;
......@@ -3256,9 +3256,19 @@ void i40iw_setup_cm_core(struct i40iw_device *iwdev)
cm_core->event_wq = alloc_ordered_workqueue("iwewq",
WQ_MEM_RECLAIM);
if (!cm_core->event_wq)
goto error;
cm_core->disconn_wq = alloc_ordered_workqueue("iwdwq",
WQ_MEM_RECLAIM);
if (!cm_core->disconn_wq)
goto error;
return 0;
error:
i40iw_cleanup_cm_core(&iwdev->cm_core);
return -ENOMEM;
}
/**
......@@ -3278,8 +3288,10 @@ void i40iw_cleanup_cm_core(struct i40iw_cm_core *cm_core)
del_timer_sync(&cm_core->tcp_timer);
spin_unlock_irqrestore(&cm_core->ht_lock, flags);
destroy_workqueue(cm_core->event_wq);
destroy_workqueue(cm_core->disconn_wq);
if (cm_core->event_wq)
destroy_workqueue(cm_core->event_wq);
if (cm_core->disconn_wq)
destroy_workqueue(cm_core->disconn_wq);
}
/**
......
......@@ -1641,7 +1641,10 @@ static int i40iw_open(struct i40e_info *ldev, struct i40e_client *client)
iwdev = &hdl->device;
iwdev->hdl = hdl;
dev = &iwdev->sc_dev;
i40iw_setup_cm_core(iwdev);
if (i40iw_setup_cm_core(iwdev)) {
kfree(iwdev->hdl);
return -ENOMEM;
}
dev->back_dev = (void *)iwdev;
iwdev->ldev = &hdl->ldev;
......
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