* [PATCH AUTOSEL 4.19 11/15] scsi: target: pscsi: Clean up after failure in pscsi_map_sg()
[not found] <20210329222327.2383533-1-sashal@kernel.org>
@ 2021-03-29 22:23 ` Sasha Levin
0 siblings, 0 replies; only message in thread
From: Sasha Levin @ 2021-03-29 22:23 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Martin Wilck, Christoph Hellwig, Lee Duncan, Martin K . Petersen,
Sasha Levin, linux-scsi, target-devel
From: Martin Wilck <mwilck@suse.com>
[ 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 <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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/target/target_core_pscsi.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 47d76c862014..02c4e3beb264 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -970,6 +970,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;
}
--
2.30.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-03-29 22:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20210329222327.2383533-1-sashal@kernel.org>
2021-03-29 22:23 ` [PATCH AUTOSEL 4.19 11/15] scsi: target: pscsi: Clean up after failure in pscsi_map_sg() Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).