Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2924458pxb; Fri, 12 Feb 2021 05:11:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxw6pF5oMuoh6QEn0cR0WYShcenB1NHLTm+9FeaWDyil4GeG4BgQwxk/uWPDxOW/v/koZ5V X-Received: by 2002:a17:906:f0d0:: with SMTP id dk16mr2889412ejb.533.1613135464196; Fri, 12 Feb 2021 05:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613135464; cv=none; d=google.com; s=arc-20160816; b=lxlTp08PkznFI+z4WmxoBmNCOhkb9qc/UsTE9uJA733tHmGdBuEZWSOwDRGjcerb2A 69gM+J8/EHyILWTf3pWMv30YiVYiwMKTlJflR4m1pvr+kyCDHkOustOtF3DFCi0OIm6r Pnvx5RYgZ7uA8lpVDFSzMtFex5+gZ5+Eb86AAluLB5pYgGHzZmSdajM1E1yA/ew1qWGD CCbkvnqE1vmNXhquGKfOt49C2HCrEa5ZGlNBjAlrJwRrhahC6/+9SMLjaSkzy2YnV/5A iUO+dAsTZrniKCejjsGgjgEk4amLMqpEPbAOq1f8gnMN5I1RnCeA47gdWrP3C7PwV2eJ LDmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=po6m2zaImaMRoTuo8OSifU6/vR/1T6ObrAtEP7rKULs=; b=Nh6x/49zwuWs0DrhYi1zo2Q6+z4AwKnE0UwDx7T9DPYMl/abiAPbqQtBX6kC8oU7hv l6oI5eLWy+9n95c6xE1SN9h4v4WhgqFn5E6lWWNM7uxygQugt43dPeWhdwVj9Dp0xUj/ PMiyTNSXrNstpVIBBxQtl/YLlhPFLwu7J8VjY4OMfijrpu01GH7pkdKMSX3IDkR88II/ WYnDd/5CvmHkmNAoNGcj+JsTAElTKD4yq4Dt79vvE/V4Sp+D0t8gdEKPGV2H0qZI7Xw6 DODwHLEl7KR/dQS0Ftt+PNjiMoG2wH3TxZOoGqxlh+d6JyqtVoE8s3282fuK0w6wesxD nRoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p88si6175033edp.145.2021.02.12.05.10.38; Fri, 12 Feb 2021 05:11:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231815AbhBLNJS (ORCPT + 99 others); Fri, 12 Feb 2021 08:09:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:35898 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbhBLMrk (ORCPT ); Fri, 12 Feb 2021 07:47:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E648BAC69; Fri, 12 Feb 2021 12:46:59 +0000 (UTC) Subject: Re: [PATCH] nvme/hwmon: Return error code when registration fails To: Daniel Wagner , linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Jens Axboe , Christoph Hellwig , Keith Busch References: <20210212093015.2846-1-dwagner@suse.de> From: Hannes Reinecke Message-ID: Date: Fri, 12 Feb 2021 13:46:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210212093015.2846-1-dwagner@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Daniel Wagner > --- > > 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 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