From: mwilck@suse.com
To: "Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
"David Disseldorp" <ddiss@suse.com>,
"Jürgen Groß" <jgross@suse.com>,
"Chaitanya Kulkarni" <Chaitanya.Kulkarni@wdc.com>,
"Martin Wilck" <mwilck@suse.com>
Subject: [PATCH v2 2/2] target: pscsi: cleanup after failure in pscsi_map_sg()
Date: Tue, 23 Mar 2021 22:24:31 +0100 [thread overview]
Message-ID: <20210323212431.15306-2-mwilck@suse.com> (raw)
In-Reply-To: <20210323212431.15306-1-mwilck@suse.com>
From: Martin Wilck <mwilck@suse.com>
If pscsi_map_sg() fails, make sure to drop references to already
allocated bios.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
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 977362d..1c9aeab 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -937,6 +937,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.26.2
next prev parent reply other threads:[~2021-03-23 21:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 21:24 [PATCH v2 1/2] target: pscsi: avoid OOM in pscsi_map_sg() mwilck
2021-03-23 21:24 ` mwilck [this message]
2021-03-24 7:14 ` [PATCH v2 2/2] target: pscsi: cleanup after failure " Christoph Hellwig
2021-03-24 17:24 ` Lee Duncan
2021-03-24 7:14 ` [PATCH v2 1/2] target: pscsi: avoid OOM " Christoph Hellwig
2021-03-24 17:24 ` Lee Duncan
2021-03-25 3:53 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210323212431.15306-2-mwilck@suse.com \
--to=mwilck@suse.com \
--cc=Chaitanya.Kulkarni@wdc.com \
--cc=ddiss@suse.com \
--cc=hch@lst.de \
--cc=jgross@suse.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox