]> git.baikalelectronics.ru Git - kernel.git/commit
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>
Wed, 18 Jan 2023 10:40:56 +0000 (11:40 +0100)
commit3064329ca389f4381b3a443ec949b0f60ab6a9de
tree172f3435d6e42e2cecc8d41360cf7a13af13654a
parent9ec0cba641fdeaed5c365d29db9c130e36159e85
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: 868fc2e3ad62 ("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