diff mbox

IB/ucma: check workqueue allocation before usage

Message ID 1442520259-2248-1-git-send-email-sasha.levin@oracle.com (mailing list archive)
State Accepted
Headers show

Commit Message

Sasha Levin Sept. 17, 2015, 8:04 p.m. UTC
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 <sasha.levin@oracle.com>
---
 drivers/infiniband/core/ucma.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Hefty, Sean Sept. 17, 2015, 8:10 p.m. UTC | #1
What kernel is this patch against?

> 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 <sasha.levin@oracle.com>
> ---
>  drivers/infiniband/core/ucma.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/ucma.c
> b/drivers/infiniband/core/ucma.c
> index a53fc9b..30467d1 100644
> --- a/drivers/infiniband/core/ucma.c
> +++ b/drivers/infiniband/core/ucma.c
> @@ -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;
> --
> 1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sasha Levin Sept. 17, 2015, 8:14 p.m. UTC | #2
On 09/17/2015 04:10 PM, Hefty, Sean wrote:
> What kernel is this patch against?

Patch is against linux-next.


Thanks,
Sasha

>> 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 <sasha.levin@oracle.com>
>> ---
>>  drivers/infiniband/core/ucma.c |    7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/core/ucma.c
>> b/drivers/infiniband/core/ucma.c
>> index a53fc9b..30467d1 100644
>> --- a/drivers/infiniband/core/ucma.c
>> +++ b/drivers/infiniband/core/ucma.c
>> @@ -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;
>> --
>> 1.7.10.4
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe Sept. 17, 2015, 10:59 p.m. UTC | #3
On Thu, Sep 17, 2015 at 04:04:19PM -0400, Sasha Levin wrote:
> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sasha Levin Oct. 1, 2015, 2:54 p.m. UTC | #4
On 09/17/2015 06:59 PM, Jason Gunthorpe wrote:
> On Thu, Sep 17, 2015 at 04:04:19PM -0400, Sasha Levin wrote:
>> 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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Ledford Oct. 20, 2015, 5:38 p.m. UTC | #5
On 10/01/2015 10:54 AM, Sasha Levin wrote:
> On 09/17/2015 06:59 PM, Jason Gunthorpe wrote:
>> On Thu, Sep 17, 2015 at 04:04:19PM -0400, Sasha Levin wrote:
>>> 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.
diff mbox

Patch

diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index a53fc9b..30467d1 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -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;