Skip to content

Commit de95909

Browse files
naotamartinkpetersen
authored andcommitted
scsi: target: pscsi: Fix bio_put() for error case
As of commit 066ff57 ("block: turn bio_kmalloc into a simple kmalloc wrapper"), a bio allocated by bio_kmalloc() must be freed by bio_uninit() and kfree(). That is not done properly for the error case, hitting WARN and NULL pointer dereference in bio_free(). Fixes: 066ff57 ("block: turn bio_kmalloc into a simple kmalloc wrapper") CC: [email protected] # 6.1+ Signed-off-by: Naohiro Aota <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b5fc07a commit de95909

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/target/target_core_pscsi.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -907,12 +907,15 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
907907

908908
return 0;
909909
fail:
910-
if (bio)
911-
bio_put(bio);
910+
if (bio) {
911+
bio_uninit(bio);
912+
kfree(bio);
913+
}
912914
while (req->bio) {
913915
bio = req->bio;
914916
req->bio = bio->bi_next;
915-
bio_put(bio);
917+
bio_uninit(bio);
918+
kfree(bio);
916919
}
917920
req->biotail = NULL;
918921
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;

0 commit comments

Comments
 (0)