This is a note to let you know that I've just added the patch titled scsi: snic: Fix double free in snic_tgt_create() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: scsi-snic-fix-double-free-in-snic_tgt_create.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 1bd3a76880b2bce017987cf53780b372cf59528e Mon Sep 17 00:00:00 2001 From: Zhu Wang <wangzhu9@xxxxxxxxxx> Date: Sat, 19 Aug 2023 08:39:41 +0000 Subject: scsi: snic: Fix double free in snic_tgt_create() From: Zhu Wang <wangzhu9@xxxxxxxxxx> 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@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230819083941.164365-1-wangzhu9@xxxxxxxxxx Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/scsi/snic/snic_disc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/scsi/snic/snic_disc.c +++ b/drivers/scsi/snic/snic_disc.c @@ -317,12 +317,11 @@ snic_tgt_create(struct snic *snic, struc "Snic Tgt: device_add, with err = %d\n", ret); - put_device(&tgt->dev); put_device(&snic->shost->shost_gendev); spin_lock_irqsave(snic->shost->host_lock, flags); list_del(&tgt->list); spin_unlock_irqrestore(snic->shost->host_lock, flags); - kfree(tgt); + put_device(&tgt->dev); tgt = NULL; return tgt; Patches currently in stable-queue which might be from wangzhu9@xxxxxxxxxx are queue-5.15/scsi-snic-fix-double-free-in-snic_tgt_create.patch queue-5.15/scsi-core-raid_class-remove-raid_component_add.patch