Commit e7bcd74f authored by Yang Yingliang's avatar Yang Yingliang Committed by sanglipeng
Browse files

Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()

stable inclusion
from stable-v5.10.157
commit 8dca384970acd94dd88aee60b1264e81e48d4ad1
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7MU59

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=8dca384970acd94dd88aee60b1264e81e48d4ad1



--------------------------------

[ Upstream commit 25c94b05 ]

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: 09d50ff8 ("Staging: hv: make the Hyper-V virtual bus code build")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/20221119081135.1564691-3-yangyingliang@huawei.com


Signed-off-by: default avatarWei Liu <wei.liu@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 3ccdf3ad
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment