Skip to content

Commit 78570f8

Browse files
dwsuseChristoph Hellwig
authored andcommitted
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: ed7770f ("nvme/hwmon: rework to avoid devm allocation") Signed-off-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent 6e6a682 commit 78570f8

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

drivers/nvme/host/hwmon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ int nvme_hwmon_init(struct nvme_ctrl *ctrl)
248248
if (IS_ERR(hwmon)) {
249249
dev_warn(dev, "Failed to instantiate hwmon device\n");
250250
kfree(data);
251+
return PTR_ERR(hwmon);
251252
}
252253
ctrl->hwmon_device = hwmon;
253254
return 0;

0 commit comments

Comments
 (0)