RDMA/srp: Fix potential fast registration list leak
Subsystems (2)
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.
--- drivers/infiniband/ulp/srp/ib_srp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/srp/ib_srp.c +3 -1
@@ -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
[email protected]
AI reviewSashiko 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 anexit_cmd_privcallback. 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")Signed-off-by Guangshuo Li <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 3 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 anexit_cmd_privcallback. Release the list on this error path.
Leon Romanovsky
AppliedQuoted 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 anexit_cmd_privcallback. 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]>