Skip to content

Commit

Permalink
IB/ucma: check workqueue allocation before usage
Browse files Browse the repository at this point in the history
Allocating a workqueue might fail, which wasn't checked so far and would
lead to NULL ptr derefs when an attempt to use it was made.

Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
sashalevin authored and dledford committed Oct 20, 2015
1 parent b3b51f9 commit 0174b38
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1624,11 +1624,16 @@ static int ucma_open(struct inode *inode, struct file *filp)
if (!file)
return -ENOMEM;

file->close_wq = create_singlethread_workqueue("ucma_close_id");
if (!file->close_wq) {
kfree(file);
return -ENOMEM;
}

INIT_LIST_HEAD(&file->event_list);
INIT_LIST_HEAD(&file->ctx_list);
init_waitqueue_head(&file->poll_wait);
mutex_init(&file->mut);
file->close_wq = create_singlethread_workqueue("ucma_close_id");

filp->private_data = file;
file->filp = filp;
Expand Down

0 comments on commit 0174b38

Please sign in to comment.