* [PATCH] nvme/hwmon: Return error code when registration fails
@ 2021-02-12 9:30 Daniel Wagner
2021-02-12 12:46 ` Hannes Reinecke
2021-02-24 9:14 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Wagner @ 2021-02-12 9:30 UTC (permalink / raw)
To: linux-nvme
Cc: Daniel Wagner, linux-kernel, Jens Axboe, Hannes Reinecke,
Keith Busch, Christoph Hellwig
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: ec420cdcfab4 ("nvme/hwmon: rework to avoid devm allocation")
Cc: Hannes Reinecke <hare@suse.de>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
This patch is against linux-block/for-next.
drivers/nvme/host/hwmon.c | 1 +
1 file changed, 1 insertion(+)
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;
--
2.29.2
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme/hwmon: Return error code when registration fails
2021-02-12 9:30 [PATCH] nvme/hwmon: Return error code when registration fails Daniel Wagner
@ 2021-02-12 12:46 ` Hannes Reinecke
2021-02-24 9:14 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2021-02-12 12:46 UTC (permalink / raw)
To: Daniel Wagner, linux-nvme
Cc: Jens Axboe, Keith Busch, linux-kernel, Christoph Hellwig
On 2/12/21 10:30 AM, Daniel Wagner wrote:
> 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: ec420cdcfab4 ("nvme/hwmon: rework to avoid devm allocation")
> Cc: Hannes Reinecke <hare@suse.de>
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
> ---
>
> This patch is against linux-block/for-next.
>
> drivers/nvme/host/hwmon.c | 1 +
> 1 file changed, 1 insertion(+)
>
> 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;
>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +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
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme/hwmon: Return error code when registration fails
2021-02-12 9:30 [PATCH] nvme/hwmon: Return error code when registration fails Daniel Wagner
2021-02-12 12:46 ` Hannes Reinecke
@ 2021-02-24 9:14 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-02-24 9:14 UTC (permalink / raw)
To: Daniel Wagner
Cc: linux-kernel, linux-nvme, Jens Axboe, Hannes Reinecke,
Keith Busch, Christoph Hellwig
Thanks,
applied to nvme-5.12.
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-24 9:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-12 9:30 [PATCH] nvme/hwmon: Return error code when registration fails Daniel Wagner
2021-02-12 12:46 ` Hannes Reinecke
2021-02-24 9:14 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).