[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a58de23b-40c2-4534-cae0-36b1e42f2d45@suse.de>
Date: Fri, 12 Feb 2021 13:46:59 +0100
From: Hannes Reinecke <hare@...e.de>
To: Daniel Wagner <dwagner@...e.de>, linux-nvme@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org, Jens Axboe <axboe@...com>,
Christoph Hellwig <hch@....de>, Keith Busch <kbusch@...nel.org>
Subject: Re: [PATCH] nvme/hwmon: Return error code when registration fails
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@...e.de>
> Signed-off-by: Daniel Wagner <dwagner@...e.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@...e.de>
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@...e.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
Powered by blists - more mailing lists