nvme-hwmon: Return error code when registration fails
authorDaniel Wagner <dwagner@suse.de>
Fri, 12 Feb 2021 09:30:15 +0000 (10:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 30 Oct 2022 08:41:17 +0000 (09:41 +0100)
commit67106ac27243313beb58097449555f92ea5947ec
tree2333a9961c635ae6d6b9328f7f6a6803ebe785a0
parentbc17f727b005921fc3b8651daefa053200c57cf0
nvme-hwmon: Return error code when registration fails

[ Upstream commit 78570f8873c8cd44c12714c7fa7db2601ec5617d ]

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: ed7770f66286 ("nvme/hwmon: rework to avoid devm allocation")
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Stable-dep-of: c94b7f9bab22 ("nvme-hwmon: kmalloc the NVME SMART log buffer")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/hwmon.c