public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd()
@ 2015-05-30  6:10 Roland Dreier
       [not found] ` <1432966231-12125-1-git-send-email-roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Dreier @ 2015-05-30  6:10 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Selvin Xavier, Devesh Sharma, Mitesh Ahuja,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

From: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>

If ocrdma_get_pd_num() fails, then we need to free the pd struct we allocated.

This was detected by Coverity (CID 1271245).

Signed-off-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 9dcb66077d6c..fcb86749efc9 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -375,7 +375,12 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
 
 	if (dev->pd_mgr->pd_prealloc_valid) {
 		status = ocrdma_get_pd_num(dev, pd);
-		return (status == 0) ? pd : ERR_PTR(status);
+		if (status == 0) {
+			return pd;
+		} else {
+			kfree(pd);
+			return ERR_PTR(status);
+		}
 	}
 
 retry:
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd()
       [not found] ` <1432966231-12125-1-git-send-email-roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
@ 2015-05-30 15:26   ` Doug Ledford
       [not found]     ` <1432999586.114391.158.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Ledford @ 2015-05-30 15:26 UTC (permalink / raw)
  To: Roland Dreier
  Cc: Selvin Xavier, Devesh Sharma, Mitesh Ahuja,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1239 bytes --]

On Fri, 2015-05-29 at 23:10 -0700, Roland Dreier wrote:
> From: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
> 
> If ocrdma_get_pd_num() fails, then we need to free the pd struct we allocated.
> 
> This was detected by Coverity (CID 1271245).
> 
> Signed-off-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>

Thanks, series applied.

> ---
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index 9dcb66077d6c..fcb86749efc9 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -375,7 +375,12 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
>  
>  	if (dev->pd_mgr->pd_prealloc_valid) {
>  		status = ocrdma_get_pd_num(dev, pd);
> -		return (status == 0) ? pd : ERR_PTR(status);
> +		if (status == 0) {
> +			return pd;
> +		} else {
> +			kfree(pd);
> +			return ERR_PTR(status);
> +		}
>  	}
>  
>  retry:


-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
              GPG KeyID: 0E572FDD


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd()
       [not found]     ` <1432999586.114391.158.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2015-06-01  5:24       ` Devesh Sharma
  0 siblings, 0 replies; 3+ messages in thread
From: Devesh Sharma @ 2015-06-01  5:24 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Roland Dreier, Selvin Xavier, Devesh Sharma, Mitesh Ahuja,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA

Acked-By: Devesh Sharma <devesh.sharma-1wcpHE2jlwO1Z/+hSey0Gg@public.gmane.org>

On Sat, May 30, 2015 at 8:56 PM, Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> On Fri, 2015-05-29 at 23:10 -0700, Roland Dreier wrote:
>> From: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
>>
>> If ocrdma_get_pd_num() fails, then we need to free the pd struct we allocated.
>>
>> This was detected by Coverity (CID 1271245).
>>
>> Signed-off-by: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
>
> Thanks, series applied.
>
>> ---
>>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
>> index 9dcb66077d6c..fcb86749efc9 100644
>> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
>> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
>> @@ -375,7 +375,12 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
>>
>>       if (dev->pd_mgr->pd_prealloc_valid) {
>>               status = ocrdma_get_pd_num(dev, pd);
>> -             return (status == 0) ? pd : ERR_PTR(status);
>> +             if (status == 0) {
>> +                     return pd;
>> +             } else {
>> +                     kfree(pd);
>> +                     return ERR_PTR(status);
>> +             }
>>       }
>>
>>  retry:
>
>
> --
> Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>               GPG KeyID: 0E572FDD
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-01  5:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-30  6:10 [PATCH 1/3] RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd() Roland Dreier
     [not found] ` <1432966231-12125-1-git-send-email-roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-05-30 15:26   ` Doug Ledford
     [not found]     ` <1432999586.114391.158.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-01  5:24       ` Devesh Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox