On 3/23/21 2:24 PM, mwilck@xxxxxxxx wrote: > From: Martin Wilck <mwilck@xxxxxxxx> > > If pscsi_map_sg() fails, make sure to drop references to already > allocated bios. > > Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> > --- > 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@xxxxxxxx>