Commit 9cabb0fb authored by Daniel Wagner's avatar Daniel Wagner Committed by Lipeng Sang
Browse files

nvme-hwmon: Return error code when registration fails

stable inclusion
from stable-v5.10.152
commit 67106ac27243313beb58097449555f92ea5947ec
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I73HJ0

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



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

[ Upstream commit 78570f88 ]

The hwmon pointer wont be NULL if the registration fails. Though the
exit code path will assign it to ctrl->hwmon_device. Later
nvme_hwmon_exit() will try to free the invalid pointer. Avoid this by
returning the error code from hwmon_device_register_with_info().

Fixes: ed7770f6 ("nvme/hwmon: rework to avoid devm allocation")
Signed-off-by: default avatarDaniel Wagner <dwagner@suse.de>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Stable-dep-of: c94b7f9b ("nvme-hwmon: kmalloc the NVME SMART log buffer")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarLipeng Sang <sanglipeng1@jd.com>
parent 42f7d489
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment