]> git.baikalelectronics.ru Git - kernel.git/commit
Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()
authorYang Yingliang <yangyingliang@huawei.com>
Sat, 19 Nov 2022 08:11:35 +0000 (16:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 8 Dec 2022 10:22:58 +0000 (11:22 +0100)
commit3aaeef309a68b2eb69eaf81fc1828f3faddc4c37
treef838dd2c01abf27debd1e227eb4f141f55b9b646
parentc7caf991a7339e225c9d35c99315e666eca4bbfc
Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()

[ Upstream commit f603b5ba397a94bb73687c2766acbe857bb1d416 ]

If device_register() returns error in vmbus_device_register(),
the name allocated by dev_set_name() must be freed. As comment
of device_register() says, it should use put_device() to give
up the reference in the error path. So fix this by calling
put_device(), then the name can be freed in kobject_cleanup().

Fixes: eba68b3942d9 ("Staging: hv: make the Hyper-V virtual bus code build")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20221119081135.1564691-3-yangyingliang@huawei.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hv/vmbus_drv.c