Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2893353pxb; Tue, 12 Jan 2021 00:49:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiM+yl91vhaESz08JuwPijAe+8AooBBk96xujlmrJTOStsJ+eTgnzZ3XnIejDrGYnZCVdX X-Received: by 2002:a17:906:d8dc:: with SMTP id re28mr2524968ejb.168.1610441394476; Tue, 12 Jan 2021 00:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610441394; cv=none; d=google.com; s=arc-20160816; b=bOCaBdjaOywITZ1Y0NbRtaZC3EumxlzyfPcmNq4R52jIDojp6r5JoEJIurj04XM2H9 S3F66O9V3ghAs2cxO0kRdugyzFKl8MxvYK0mWD+/biBGUffCLTvJkruBEclLOCP4cRz6 IIabAxpKCpN15XHrFYmf+m/RJRtaMxxfz4Tb1u8XHqQp55EkseFcsfcNVsoaTiDhvIBF Pe+UJwe5z43h1bIcUfZj1SMRKvuzceaG+fhmX2o4QZf5vBkGDUPhLireNvbIvj/JoPSv Q2OZb7bBeNfK/e1SKhrTaex/HC3w1c4nTT9ZmuCiz6LEF1yMeXqcWxE2A+sADcGpJYuB 4S8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=pK7p9MXJ2c1xGClnsftbE+W+4CjRSWx4Lb1xrurTMRs=; b=aOuax8FbhOmr5ZK39b+mKJQ+J1s7nBLNnDoMlJPphAAoqrvM28K9FuIiQ8fZz0YrZi bXDWlgTm4+hCxYNAsan35/Xszr78SQllsu3oTZzjBpOowxAH+zT141vg2zQhGP7YOn6b S0kYiPHbogJ8hp82HVr1rbkhhgSLW3KRFnDJrVOiQeHzCabIiNKDlARHxa/nCR5RiX6R 3KCAK92JlVw+vGpKeCb7s6Kr6HUczIZGiTiVq11+p38ZaHHeVxSQBe597EmE2l90y9m7 jQYoI7B/+kGMOU469DpAFFqtbRod+RUMWMSqf4a1YJUa7xBov/uLN0f0qJO5UNWOAGVA qLVw== 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 d2si988920edd.145.2021.01.12.00.49.31; Tue, 12 Jan 2021 00:49:54 -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 S1729854AbhAKQTj (ORCPT + 99 others); Mon, 11 Jan 2021 11:19:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:59104 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729200AbhAKQTi (ORCPT ); Mon, 11 Jan 2021 11:19:38 -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 8F6A4AD57; Mon, 11 Jan 2021 16:18:57 +0000 (UTC) Date: Mon, 11 Jan 2021 17:18:57 +0100 From: Daniel Wagner To: Hannes Reinecke Cc: Enzo Matsumiya , Sagi Grimberg , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Jens Axboe , Keith Busch , Christoph Hellwig Subject: Re: [PATCH] nvme: hwmon: fix crash on device teardown Message-ID: <20210111161857.okecoo4h4b4prpic@beryllium.lan> References: <20201209213228.5044-1-ematsumiya@suse.de> <4ebb1b8c-4bb0-6ebf-3417-d4aee1bdd3a8@suse.de> <20201230143805.2v4izgkzbnisssvr@beryllium.lan> <20201230151653.ozlqlwef7f2tarwz@beryllium.lan> <20201230153138.4f2jd2yd2vkqndby@beryllium.lan> <20210104210610.hliiupywksawgei3@hyori> <20210105094545.3tq7c6ev5yn3bhyi@beryllium.lan> <412d45ef-40af-24c3-4aa2-042ecbba05cd@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <412d45ef-40af-24c3-4aa2-042ecbba05cd@suse.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 11, 2021 at 05:00:18PM +0100, Hannes Reinecke wrote: > Yeah, using the controller node for devm allocations is quite dodgy. > Does this one help? > > diff --git a/drivers/nvme/host/hwmon.c b/drivers/nvme/host/hwmon.c > index 6fdd07fb3001..7260af028cf7 100644 > --- a/drivers/nvme/host/hwmon.c > +++ b/drivers/nvme/host/hwmon.c > @@ -226,7 +226,7 @@ static const struct hwmon_chip_info > > int nvme_hwmon_init(struct nvme_ctrl *ctrl) > { > - struct device *dev = ctrl->dev; > + struct device *dev = ctrl->device; This is what I tried. Yes, it fixes the obvious problem and moves the hwmon entry under the nvme entry. When the nvme is destroyed, the hwmon entry is not accessible. But as ctrl->device is not managed by devm the resources are not freed.