]> git.baikalelectronics.ru Git - kernel.git/commit
drivers: dio: fix possible memory leak in dio_init()
authorYang Yingliang <yangyingliang@huawei.com>
Wed, 9 Nov 2022 06:40:36 +0000 (14:40 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:21 +0000 (11:41 +0100)
commit5fb31dd7a454942ea2ba503f3d0e2f9427180052
tree4078a21b8e0a9dd746f3b77b307941b15e4a33f7
parent934f402c9fb8f2faca8b4b896c1d171e21ee055d
drivers: dio: fix possible memory leak in dio_init()

[ Upstream commit e63e99397b2613d50a5f4f02ed07307e67a190f1 ]

If device_register() returns error, the 'dev' and name needs be
freed. Add a release function, and then call put_device() in the
error path, so the name is freed in kobject_cleanup() and to the
'dev' is freed in release function.

Fixes: 33dc8269f10b ("m68k: dio - Kill warn_unused_result warnings")
Fixes: 13e0419aca34 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221109064036.1835346-1-yangyingliang@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dio/dio.c