]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
NTB: ntb_transport: fix possible memory leak while device_register() fails
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 10 Nov 2022 15:19:17 +0000 (23:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Aug 2023 09:33:44 +0000 (11:33 +0200)
commit401807fec2c5d7effa15b60ca7f8ef4f52fa4073
tree38ac4f3b16711390005240322802bc724a164a6c
parentf2461f51e5b6dc7c1c5309f5d2bf88deed85a9c4
NTB: ntb_transport: fix possible memory leak while device_register() fails

[ Upstream commit 8623ccbfc55d962e19a3537652803676ad7acb90 ]

If device_register() returns error, 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(), and client_dev is freed
in ntb_transport_client_release().

Fixes: fce8a7bb5b4b ("PCI-Express Non-Transparent Bridge Support")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/ntb/ntb_transport.c