Message ID | 20210323212431.15306-2-mwilck@suse.com |
---|---|
State | New |
Headers | show |
Series | None | expand |
On Tue, Mar 23, 2021 at 10:24:31PM +0100, mwilck@suse.com wrote: > 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> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>
On 3/23/21 2:24 PM, mwilck@suse.com wrote: > 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; > } > > Reviewed-by: Lee Duncan <lduncan@suse.com>
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; }