Skip to content

Commit 5812d04

Browse files
Max Gurtovoykeithbusch
authored andcommitted
nvmet-loop: fix possible leakage during error flow
During nvme_loop_queue_rq error flow, one must call nvme_cleanup_cmd since it's symmetric to nvme_setup_cmd. Signed-off-by: Max Gurtovoy <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent ac1c4e1 commit 5812d04

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/nvme/target/loop.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,10 @@ static blk_status_t nvme_loop_queue_rq(struct blk_mq_hw_ctx *hctx,
157157
iod->sg_table.sgl = iod->first_sgl;
158158
if (sg_alloc_table_chained(&iod->sg_table,
159159
blk_rq_nr_phys_segments(req),
160-
iod->sg_table.sgl, SG_CHUNK_SIZE))
160+
iod->sg_table.sgl, SG_CHUNK_SIZE)) {
161+
nvme_cleanup_cmd(req);
161162
return BLK_STS_RESOURCE;
163+
}
162164

163165
iod->req.sg = iod->sg_table.sgl;
164166
iod->req.sg_cnt = blk_rq_map_sg(req->q, req, iod->sg_table.sgl);

0 commit comments

Comments
 (0)