mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 05:44:11 +00:00
scsi: target: pscsi: Fix bio_put() for error case
As of commit066ff57101
("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:066ff57101
("block: turn bio_kmalloc into a simple kmalloc wrapper") CC: stable@vger.kernel.org # 6.1+ Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Link: https://lore.kernel.org/r/20240214144356.101814-1-naohiro.aota@wdc.com Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
b5fc07a5fb
commit
de959094eb
1 changed files with 6 additions and 3 deletions
|
@ -907,12 +907,15 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
if (bio)
|
if (bio) {
|
||||||
bio_put(bio);
|
bio_uninit(bio);
|
||||||
|
kfree(bio);
|
||||||
|
}
|
||||||
while (req->bio) {
|
while (req->bio) {
|
||||||
bio = req->bio;
|
bio = req->bio;
|
||||||
req->bio = bio->bi_next;
|
req->bio = bio->bi_next;
|
||||||
bio_put(bio);
|
bio_uninit(bio);
|
||||||
|
kfree(bio);
|
||||||
}
|
}
|
||||||
req->biotail = NULL;
|
req->biotail = NULL;
|
||||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||||
|
|
Loading…
Reference in a new issue