rapidio: rio: fix possible name leak in rio_register_mport()
authorYang Yingliang <yangyingliang@huawei.com>
Mon, 14 Nov 2022 15:26:36 +0000 (23:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:03 +0000 (13:14 +0100)
commita47de2fd3f88a7788be19f94ade72c2244a98045
tree4fa0cd36c3411c40b1341daf95126fba38d1ed71
parentec3f04f74f50d0b6bac04d795c93c2b852753a7a
rapidio: rio: fix possible name leak in rio_register_mport()

[ Upstream commit e92a216d16bde65d21a3227e0fb2aa0794576525 ]

If device_register() returns error, the name allocated by dev_set_name()
need be freed.  It should use put_device() to give up the reference in the
error path, so that the name can be freed in kobject_cleanup(), and
list_del() is called to delete the port from rio_mports.

Link: https://lkml.kernel.org/r/20221114152636.2939035-3-yangyingliang@huawei.com
Fixes: 2aaf308b95b2 ("rapidio: rework device hierarchy and introduce mport class of devices")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/rapidio/rio.c