Skip to contentSkip to conversation

IB/ucma: check workqueue allocation before usage

PATCH In review Sasha Levin 5 participants 6 messages Sep 17, 2015 – Oct 20, 2015 2 messages not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/infiniband/core/ucma.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +6 -1
index a53fc9b..30467d1 100644
@@ -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;
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1442520259-2248-1-git-send-email-sasha.levin-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org

#2 lore raw

What kernel is this patch against?

Quoted 31 lines

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.

---
 drivers/infiniband/core/ucma.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +6 -1
index a53fc9b..30467d1 100644
@@ -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;
Quoted 3 lines

file->filp = filp;
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1828884A29C6694DAF28B7E6B8A82373A903C056-P5GAC/[email protected]

#4 lore raw
Quoted 1 line · Sean

What kernel is this patch against?

Patch is against linux-next.

Thanks,
Sasha

Quoted 30 lines
Quoted 30 lines

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.

---
 drivers/infiniband/core/ucma.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/core/ucma.c +6 -1
index a53fc9b..30467d1 100644
@@ -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");
 
Quoted 5 lines
Quoted 4 lines
drivers/infiniband/core/ucma.c +0 -0
 	filp->private_data = file;

file->filp = filp;
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Sasha Levin
Quoted 2 lines · Sasha Levin

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.

Indeed.

Yishai, please check this and check the other patches you've sent to see if they have a similar error.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 8 lines · Jason Gunthorpe
Quoted 2 lines · Sasha Levin

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.

Indeed.

Yishai, please check this and check the other patches you've sent to see if they have a similar error.

Ping? It doesn't seem that the patch got anywhere.

Thanks,
Sasha

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 11 lines · Sasha Levin
Quoted 8 lines · Jason Gunthorpe
Quoted 2 lines · Sasha Levin

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.

Indeed.

Yishai, please check this and check the other patches you've sent to see if they have a similar error.

Ping? It doesn't seem that the patch got anywhere.

Sorry, I took the "it applies to linux-next" to mean it wasn't against my tree yet and was against upcoming patches. That wasn't the case. It's been applied.

Signature · 2 lines
Doug Ledford <[email protected]>
              GPG KeyID: 0E572FDD