mISDN: fix possible memory leak in mISDN_register_device()
authorYang Yingliang <yangyingliang@huawei.com>
Mon, 31 Oct 2022 12:13:40 +0000 (20:13 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2022 17:15:29 +0000 (18:15 +0100)
commit029d5b7688a2f3a86f2a3be5a6ba9cc968c80e41
treed5d319a3275d947c78bc8cf48a6a7fde02c59c0a
parent3e2129c67daca21043a26575108f6286c85e71f6
mISDN: fix possible memory leak in mISDN_register_device()

[ Upstream commit e7d1d4d9ac0dfa40be4c2c8abd0731659869b297 ]

Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's
bus_id string array"), the name of device is allocated dynamically,
add put_device() to give up the reference, so that the name can be
freed in kobject_cleanup() when the refcount is 0.

Set device class before put_device() to avoid null release() function
WARN message in device_release().

Fixes: 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/isdn/mISDN/core.c