Skip to content

Commit 36fa766

Browse files
mwilckmartinkpetersen
authored andcommitted
scsi: target: pscsi: Clean up after failure in pscsi_map_sg()
If pscsi_map_sg() fails, make sure to drop references to already allocated bios. Link: https://lore.kernel.org/r/20210323212431.15306-2-mwilck@suse.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Lee Duncan <lduncan@suse.com> Signed-off-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 077ce02 commit 36fa766

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/target/target_core_pscsi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
938938

939939
return 0;
940940
fail:
941+
if (bio)
942+
bio_put(bio);
943+
while (req->bio) {
944+
bio = req->bio;
945+
req->bio = bio->bi_next;
946+
bio_put(bio);
947+
}
948+
req->biotail = NULL;
941949
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
942950
}
943951

0 commit comments

Comments
 (0)