Re: [PATCH 4/5] RDMA/srp: Fix a recently introduced memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 5/12/2021 6:27 AM, Bart Van Assche wrote:
Only allocate an mr_list if it will be used and if it will be freed.

Cc: Max Gurtovoy <maxg@xxxxxxxxxxxx>
Cc: Nicolas Morey-Chaisemartin <nmoreychaisemartin@xxxxxxxx>
Fixes: f273ad4f8d90 ("RDMA/srp: Remove support for FMR memory registration")
Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
  drivers/infiniband/ulp/srp/ib_srp.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 0f66bf015db6..52db42af421b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1009,12 +1009,13 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
for (i = 0; i < target->req_ring_size; ++i) {
  		req = &ch->req_ring[i];
-		mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
-					GFP_KERNEL);
-		if (!mr_list)
-			goto out;
-		if (srp_dev->use_fast_reg)
+		if (srp_dev->use_fast_reg) {
+			mr_list = kmalloc_array(target->mr_per_cmd,
+						sizeof(void *), GFP_KERNEL);
+			if (!mr_list)
+				goto out;
  			req->fr_list = mr_list;
+		}
  		req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL);
  		if (!req->indirect_desc)
  			goto out;

Looks good,

maybe we can remove the local mr_list variable while we're here ?

otherwise,

Reviewed-by: Max Gurtovoy <mgurtovoy@xxxxxxxxxx>




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux