Patch "scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus()" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus()

to the 4.19-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-target-tcm_loop-fix-possible-name-leak-in-tcm_l.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit db139547d4e46696d45938d21e677ad3d8a7b7cb
Author: Yang Yingliang <yangyingliang@xxxxxxxxxx>
Date:   Tue Nov 15 09:50:42 2022 +0800

    scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus()
    
    [ Upstream commit bc68e428d4963af0201e92159629ab96948f0893 ]
    
    If device_register() fails in tcm_loop_setup_hba_bus(), the name allocated
    by dev_set_name() need be freed. As comment of device_register() says, it
    should use put_device() to give up the reference in the error path. So fix
    this by calling put_device(), then the name can be freed in kobject_cleanup().
    The 'tl_hba' will be freed in tcm_loop_release_adapter(), so it don't need
    goto error label in this case.
    
    Fixes: 3703b2c5d041 ("[SCSI] tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module")
    Signed-off-by: Yang Yingliang <yangyingliang@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20221115015042.3652261-1-yangyingliang@xxxxxxxxxx
    Reviewed-by: Mike Christie <michael.chritie@xxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index bc8918f382e4..80b74db4048b 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -409,6 +409,7 @@ static int tcm_loop_setup_hba_bus(struct tcm_loop_hba *tl_hba, int tcm_loop_host
 	ret = device_register(&tl_hba->dev);
 	if (ret) {
 		pr_err("device_register() failed for tl_hba->dev: %d\n", ret);
+		put_device(&tl_hba->dev);
 		return -ENODEV;
 	}
 
@@ -1103,7 +1104,7 @@ static struct se_wwn *tcm_loop_make_scsi_hba(
 	 */
 	ret = tcm_loop_setup_hba_bus(tl_hba, tcm_loop_hba_no_cnt);
 	if (ret)
-		goto out;
+		return ERR_PTR(ret);
 
 	sh = tl_hba->sh;
 	tcm_loop_hba_no_cnt++;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux