]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 15 Nov 2022 01:50:42 +0000 (09:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Nov 2022 16:42:20 +0000 (17:42 +0100)
commitafa877fff15ed15c22b7f8c227a2fe1b9436c5a4
tree839297b16d704fd3d0fc61587280513dbc418e34
parent2013734562df3bd36f7ac3cb9e9d623eed9c5fcd
scsi: target: tcm_loop: Fix possible name leak in tcm_loop_setup_hba_bus()

[ Upstream commit 78e660e526e93d1b9a7109f177bfcf3cdbf9213b ]

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: 0aca937055f0 ("[SCSI] tcm_loop: Add multi-fabric Linux/SCSI LLD fabric module")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221115015042.3652261-1-yangyingliang@huawei.com
Reviewed-by: Mike Christie <michael.chritie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/target/loopback/tcm_loop.c