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

powercap: fix possible name leak in powercap_register_zone()

stable inclusion
from stable-v5.10.173
commit 0e7a569929acdea82e56f0d0c2f45ff85dc25161
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8BFR3

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



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

[ Upstream commit 1b6599f7 ]

In the error path after calling dev_set_name(), the device
name is leaked. To fix this, calling dev_set_name() before
device_register(), and call put_device() if it returns error.

All the resources is released in powercap_release(), so it
can return from powercap_register_zone() directly.

Fixes: 75d2364e ("PowerCap: Add class driver")
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 30cddbca
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment