WSL2-Linux-Kernel/drivers/scsi/snic
Zhu Wang d3d57cdbfd scsi: snic: Fix double free in snic_tgt_create()
commit 1bd3a76880 upstream.

Commit 41320b18a0 ("scsi: snic: Fix possible memory leak if device_add()
fails") fixed the memory leak caused by dev_set_name() when device_add()
failed. However, it did not consider that 'tgt' has already been released
when put_device(&tgt->dev) is called. Remove kfree(tgt) in the error path
to avoid double free of 'tgt' and move put_device(&tgt->dev) after the
removed kfree(tgt) to avoid a use-after-free.

Fixes: 41320b18a0 ("scsi: snic: Fix possible memory leak if device_add() fails")
Signed-off-by: Zhu Wang <wangzhu9@huawei.com>
Link: https://lore.kernel.org/r/20230819083941.164365-1-wangzhu9@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-30 16:18:21 +02:00
..
Makefile
cq_desc.h
cq_enet_desc.h
snic.h
snic_attrs.c
snic_ctl.c
snic_debugfs.c
snic_disc.c scsi: snic: Fix double free in snic_tgt_create() 2023-08-30 16:18:21 +02:00
snic_disc.h
snic_fwint.h
snic_io.c
snic_io.h
snic_isr.c
snic_main.c
snic_res.c
snic_res.h
snic_scsi.c
snic_stats.h
snic_trc.c
snic_trc.h
vnic_cq.c
vnic_cq.h
vnic_cq_fw.h
vnic_dev.c
vnic_dev.h
vnic_devcmd.h
vnic_intr.c
vnic_intr.h
vnic_resource.h
vnic_snic.h
vnic_stats.h
vnic_wq.c
vnic_wq.h
wq_enet_desc.h