nvme/hwmon: Return error code when registration fails
Subsystems (2)
PATCH 1/1 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().
---
This patch is against linux-block/for-next.
drivers/nvme/host/hwmon.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/hwmon.c +1 -0
@@ -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 ;
Signature · 7 lines
2.29.2 _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Quoted 21 lines · Daniel Wagner
The hwmon pointer wont be NULL if the registration fails. Though the exit code path will assign it to
ctrl->hwmon_device. Laternvme_hwmon_exit()will try to free the invalid pointer. Avoid this by returning the error code fromhwmon_device_register_with_info().Fixes ec420cdcfab4 ("nvme/hwmon: rework to avoid devm allocation")Cc Hannes Reinecke <[email protected]>Signed-off-by Daniel Wagner <[email protected]>---
This patch is against linux-block/for-next.
drivers/nvme/host/hwmon.c | 1 + 1 file changed, 1 insertion(+)drivers/nvme/host/hwmon.c +0
-0
drivers/nvme/host/hwmon.c int nvme_hwmon_init(struct nvme_ctrl *ctrl) · line 254
Quoted 7 lines
drivers/nvme/host/hwmon.c +1
-0@@ -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 ;
Cheers,
Hannes
Signature · 9 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer _______________________________________________ Linux-nvme mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-nvme
Thanks,
applied to nvme-5.12.
_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme