android_kernel_xiaomi_sm8350/drivers/scsi/snic
Zhu Wang 56428d89a0 scsi: snic: Fix double free in snic_tgt_create()
commit 1bd3a76880b2bce017987cf53780b372cf59528e upstream.

Commit 41320b18a0e0 ("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: 41320b18a0e0 ("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:27:27 +02:00
..
cq_desc.h
cq_enet_desc.h
Makefile
snic_attrs.c
snic_ctl.c
snic_debugfs.c
snic_disc.c
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
snic.h
vnic_cq_fw.h
vnic_cq.c
vnic_cq.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