Skip to contentSkip to conversation

RDMA/srp: Fix potential fast registration list leak

PATCH Applied Guangshuo Li 4 participants 4 messages Nov 11 – Nov 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/srp: Fix potential fast registration list leak

If the indirect descriptor allocation fails, srp_init_cmd_priv() returns without freeing the fast registration list. The failed request does not receive an exit_cmd_priv callback. Release the list on this error path.

This issue was found by our static analysis tool under development.

Fixes ad215aaea4f9 ("RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent")
---
 drivers/infiniband/ulp/srp/ib_srp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -1
index 5811f02df980..1cea1896d162 100644
@@ -996,8 +996,10 @@ static int srp_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 			goto out;
 	}
 	req->indirect_desc = kmalloc(target->indirect_size, GFP_KERNEL);
-	if (!req->indirect_desc)
+	if (!req->indirect_desc) {
+		kfree(req->fr_list);
 		goto out;
+	}
 
 	dma_addr = ib_dma_map_single(ibdev, req->indirect_desc,
 				     target->indirect_size,

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4

#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

If the indirect descriptor allocation fails, srp_init_cmd_priv() returns without freeing the fast registration list. The failed request does not receive an exit_cmd_priv callback. Release the list on this error path.

This issue was found by our static analysis tool under development.

Fixes ad215aaea4f9 ("RDMA/srp: Make struct scsi_cmnd and struct srp_request adjacent")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#3 lore raw
In reply to Guangshuo Li
Quoted 8 lines · Guangshuo Li

If the indirect descriptor allocation fails, srp_init_cmd_priv() returns without freeing the fast registration list. The failed request does not receive an exit_cmd_priv callback. Release the list on this error path.

This issue was found by our static analysis tool under development.

[...]

Applied, thanks!

[1/1] RDMA/srp: Fix potential fast registration list leak

      https://git.kernel.org/rdma/rdma/c/4ed9792fd24738

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>