sunrpc: potential memory leak in function rdma_read_xdr
Subsystems (3)
PATCH 1/1 sunrpc: potential memory leak in function rdma_read_xdr
From: Christian Engelmayer <[email protected]>
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.
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c renamed from net/sunrpc/xprtrdma/svc_rdma_recvfrom.c.orig +4 -4
@@ -397,14 +397,14 @@ static int rdma_read_xdr(struct svcxprt_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,
A message that is not in the archive (sent off-list or not yet received): [email protected]
J. Bruce Fields
AppliedQuoted 8 lines · Christian Engelmayer
From: Christian Engelmayer <[email protected]>
In case the check on
ch_countfails the cleanup path is skipped and the previously allocated memory 'rpl_map', 'chl_map' is not freed.Signed-off-by Christian Engelmayer <[email protected]>--
Reported by Coverity.
Thanks, applied (after fixing up a minor whitespace error--extra space added before tab on comment line).
rdma_read_xdr() is long. If there were a logical way to move some of that into a helper function or two, that might make it easier to read (and/or might simplify cleanup on failure).
--b.
Quoted 22 lines
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c renamed from net/sunrpc/xprtrdma/svc_rdma_recvfrom.c.orig +4
-4@@ -397,14 +397,14 @@ static int rdma_read_xdr(struct svcxprt_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,