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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 2 Nov 2022 12:34:48 +0000 (12:34 +0000)
commite7d1d4d9ac0dfa40be4c2c8abd0731659869b297
treea75a419d62c22acad066f6cfad7f3dfe9b0e1377
parente97c089d7a49f67027395ddf70bf327eeac2611e
mISDN: fix possible memory leak in mISDN_register_device()

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>
drivers/isdn/mISDN/core.c