Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sunrpc: potential memory leak in function rdma_read_xdr

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>

authored by

Christian Engelmayer and committed by
J. Bruce Fields
59fb3066 e4636d53

+4 -4
+4 -4
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
··· 397 397 if (!ch) 398 398 return 0; 399 399 400 - /* Allocate temporary reply and chunk maps */ 401 - rpl_map = svc_rdma_get_req_map(); 402 - chl_map = svc_rdma_get_req_map(); 403 - 404 400 svc_rdma_rcl_chunk_counts(ch, &ch_count, &byte_count); 405 401 if (ch_count > RPCSVC_MAXPAGES) 406 402 return -EINVAL; 403 + 404 + /* Allocate temporary reply and chunk maps */ 405 + rpl_map = svc_rdma_get_req_map(); 406 + chl_map = svc_rdma_get_req_map(); 407 407 408 408 if (!xprt->sc_frmr_pg_list_len) 409 409 sge_count = map_read_chunks(xprt, rqstp, hdr_ctxt, rmsgp,