Commit 7ec2e27a authored by Bart Van Assche's avatar Bart Van Assche Committed by Jason Gunthorpe

RDMA/srp: Fix a recently introduced memory leak

Only allocate a memory registration list if it will be used and if it will
be freed.

Link: https://lore.kernel.org/r/20210524041211.9480-5-bvanassche@acm.orgReviewed-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Fixes: f273ad4f ("RDMA/srp: Remove support for FMR memory registration")
Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 6dc26498
...@@ -998,7 +998,6 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) ...@@ -998,7 +998,6 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
struct srp_device *srp_dev = target->srp_host->srp_dev; struct srp_device *srp_dev = target->srp_host->srp_dev;
struct ib_device *ibdev = srp_dev->dev; struct ib_device *ibdev = srp_dev->dev;
struct srp_request *req; struct srp_request *req;
void *mr_list;
dma_addr_t dma_addr; dma_addr_t dma_addr;
int i, ret = -ENOMEM; int i, ret = -ENOMEM;
...@@ -1009,12 +1008,12 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) ...@@ -1009,12 +1008,12 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
for (i = 0; i < target->req_ring_size; ++i) { for (i = 0; i < target->req_ring_size; ++i) {
req = &ch->req_ring[i]; req = &ch->req_ring[i];
mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *), if (srp_dev->use_fast_reg) {
GFP_KERNEL); req->fr_list = kmalloc_array(target->mr_per_cmd,
if (!mr_list) sizeof(void *), GFP_KERNEL);
if (!req->fr_list)
goto out; goto out;
if (srp_dev->use_fast_reg) }
req->fr_list = mr_list;
req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL); req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL);
if (!req->indirect_desc) if (!req->indirect_desc)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment