From: Martin Wilck Date: Tue, 23 Mar 2021 21:24:31 +0000 (+0100) Subject: scsi: target: pscsi: Clean up after failure in pscsi_map_sg() X-Git-Tag: v5.10.79~5863 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47f8bc68ae956afdb1e0a36b5981f2f7d0b1db1d;p=platform%2Fkernel%2Flinux-rpi.git scsi: target: pscsi: Clean up after failure in pscsi_map_sg() [ Upstream commit 36fa766faa0c822c860e636fe82b1affcd022974 ] 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 Reviewed-by: Lee Duncan Signed-off-by: Martin Wilck Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 4e37fa9..723a51a 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -939,6 +939,14 @@ new_bio: 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; }