sunrpc: potential memory leak in function rdma_read_xdr
authorChristian Engelmayer <christian.engelmayer@frequentis.com>
Sat, 13 Jun 2009 22:05:26 +0000 (00:05 +0200)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Tue, 16 Jun 2009 02:34:32 +0000 (19:34 -0700)
In case the check on ch_count fails the cleanup path is skipped and the
previously allocated memory 'rpl_map', 'chl_map' is not freed.

Reported by Coverity.

Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c

index 42a6f9f2028567bc91b3860bc8204b656f7e7664..9e884383134f6536f6ba5a81e916c5999386ca98 100644 (file)
@@ -397,14 +397,14 @@ static int rdma_read_xdr(struct svcxprt_rdma *xprt,
        if (!ch)
                return 0;
 
-       /* Allocate temporary reply and chunk maps */
-       rpl_map = svc_rdma_get_req_map();
-       chl_map = svc_rdma_get_req_map();
-
        svc_rdma_rcl_chunk_counts(ch, &ch_count, &byte_count);
        if (ch_count > RPCSVC_MAXPAGES)
                return -EINVAL;
 
+       /* Allocate temporary reply and chunk maps */
+       rpl_map = svc_rdma_get_req_map();
+       chl_map = svc_rdma_get_req_map();
+
        if (!xprt->sc_frmr_pg_list_len)
                sge_count = map_read_chunks(xprt, rqstp, hdr_ctxt, rmsgp,
                                            rpl_map, chl_map, ch_count,