Skip to content

Commit 0174b38

Browse files
sashalevindledford
authored andcommitted
IB/ucma: check workqueue allocation before usage
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]>
1 parent b3b51f9 commit 0174b38

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/infiniband/core/ucma.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1624,11 +1624,16 @@ static int ucma_open(struct inode *inode, struct file *filp)
16241624
if (!file)
16251625
return -ENOMEM;
16261626

1627+
file->close_wq = create_singlethread_workqueue("ucma_close_id");
1628+
if (!file->close_wq) {
1629+
kfree(file);
1630+
return -ENOMEM;
1631+
}
1632+
16271633
INIT_LIST_HEAD(&file->event_list);
16281634
INIT_LIST_HEAD(&file->ctx_list);
16291635
init_waitqueue_head(&file->poll_wait);
16301636
mutex_init(&file->mut);
1631-
file->close_wq = create_singlethread_workqueue("ucma_close_id");
16321637

16331638
filp->private_data = file;
16341639
file->filp = filp;

0 commit comments

Comments
 (0)