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)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 1 Dec 2022 00:13:17 +0000 (16:13 -0800)
commite92a216d16bde65d21a3227e0fb2aa0794576525
treeadc0eeb86eaf74ea5069e7552e8100ea11b4ea23
parentf9574cd48679926e2a569e1957a5a1bcc8a719ac
rapidio: rio: fix possible name leak in rio_register_mport()

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>
drivers/rapidio/rio.c