diff mbox

SUNRPC: Remove resource leak in svc_rdma_send_error()

Message ID alpine.LNX.2.00.1101222233260.7746@swampdragon.chaosbits.net
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Jesper Juhl Jan. 22, 2011, 9:40 p.m. UTC
We leak the memory allocated to 'ctxt' when we return after 
'ib_dma_mapping_error()' returns !=0.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 svc_rdma_transport.c |    1 +
 1 file changed, 1 insertion(+)

  compile tested only

Comments

J. Bruce Fields March 17, 2011, 6:37 p.m. UTC | #1
On Sat, Jan 22, 2011 at 10:40:20PM +0100, Jesper Juhl wrote:
> We leak the memory allocated to 'ctxt' when we return after 
> 'ib_dma_mapping_error()' returns !=0.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

I don't know this code, but I can't see how that could be wrong....
Applying unless Tom tells me otherwise.

--b.

> ---
>  svc_rdma_transport.c |    1 +
>  1 file changed, 1 insertion(+)
> 
>   compile tested only
> 
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> index 9df1ead..1a10dcd 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -1335,6 +1335,7 @@ void svc_rdma_send_error(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rmsgp,
>  					    p, 0, length, DMA_FROM_DEVICE);
>  	if (ib_dma_mapping_error(xprt->sc_cm_id->device, ctxt->sge[0].addr)) {
>  		put_page(p);
> +		svc_rdma_put_context(ctxt, 1);
>  		return;
>  	}
>  	atomic_inc(&xprt->sc_dma_used);
> 
> 
> -- 
> Jesper Juhl <jj@chaosbits.net>            http://www.chaosbits.net/
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> Plain text mails only, please.
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tom Tucker March 17, 2011, 6:54 p.m. UTC | #2
Hi Bruce,

I believe this fix is correct.

Tom

On 3/17/11 12:37 PM, J. Bruce Fields wrote:
> On Sat, Jan 22, 2011 at 10:40:20PM +0100, Jesper Juhl wrote:
>> We leak the memory allocated to 'ctxt' when we return after
>> 'ib_dma_mapping_error()' returns !=0.
>>
>> Signed-off-by: Jesper Juhl<jj@chaosbits.net>
> I don't know this code, but I can't see how that could be wrong....
> Applying unless Tom tells me otherwise.
>
> --b.
>
>> ---
>>   svc_rdma_transport.c |    1 +
>>   1 file changed, 1 insertion(+)
>>
>>    compile tested only
>>
>> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> index 9df1ead..1a10dcd 100644
>> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
>> @@ -1335,6 +1335,7 @@ void svc_rdma_send_error(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rmsgp,
>>   					    p, 0, length, DMA_FROM_DEVICE);
>>   	if (ib_dma_mapping_error(xprt->sc_cm_id->device, ctxt->sge[0].addr)) {
>>   		put_page(p);
>> +		svc_rdma_put_context(ctxt, 1);
>>   		return;
>>   	}
>>   	atomic_inc(&xprt->sc_dma_used);
>>
>>
>> -- 
>> Jesper Juhl<jj@chaosbits.net>             http://www.chaosbits.net/
>> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
>> Plain text mails only, please.
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
index 9df1ead..1a10dcd 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
@@ -1335,6 +1335,7 @@  void svc_rdma_send_error(struct svcxprt_rdma *xprt, struct rpcrdma_msg *rmsgp,
 					    p, 0, length, DMA_FROM_DEVICE);
 	if (ib_dma_mapping_error(xprt->sc_cm_id->device, ctxt->sge[0].addr)) {
 		put_page(p);
+		svc_rdma_put_context(ctxt, 1);
 		return;
 	}
 	atomic_inc(&xprt->sc_dma_used);