Skip to content

Commit

Permalink
scsi: target: pscsi: Clean up after failure in pscsi_map_sg()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mwilck authored and martinkpetersen committed Mar 25, 2021
1 parent 077ce02 commit 36fa766
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/target/target_core_pscsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,

return 0;
fail:
if (bio)
bio_put(bio);
while (req->bio) {
bio = req->bio;
req->bio = bio->bi_next;
bio_put(bio);
}
req->biotail = NULL;
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
}

Expand Down

0 comments on commit 36fa766

Please sign in to comment.