diff options
author | Daniel Wagner <dwagner@suse.de> | 2021-02-12 12:30:15 +0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2021-03-05 15:41:03 +0300 |
commit | 78570f8873c8cd44c12714c7fa7db2601ec5617d (patch) | |
tree | 6949049843f73c1a3096f3ec3f28e0f04bafa4e6 /drivers/nvme | |
parent | 6e6a6828c517fb6819479bf5187df5f39084eb9e (diff) | |
download | linux-78570f8873c8cd44c12714c7fa7db2601ec5617d.tar.xz |
nvme-hwmon: Return error code when registration fails
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>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/host/hwmon.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c index 8f9e96986780..0a586d712920 100644 --- a/drivers/nvme/host/hwmon.c +++ b/drivers/nvme/host/hwmon.c @@ -248,6 +248,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl) if (IS_ERR(hwmon)) { dev_warn(dev, "Failed to instantiate hwmon device\n"); kfree(data); + return PTR_ERR(hwmon); } ctrl->hwmon_device = hwmon; return 0; |