Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1183044pxb; Fri, 1 Oct 2021 05:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyybe2rtcP08JAHo4bRNlLLYPWAZEltv5CL1cMb++cNSCuAzDxIifFy91G1ThtL7gcqyF+u X-Received: by 2002:a05:6402:3591:: with SMTP id y17mr14304918edc.343.1633091324690; Fri, 01 Oct 2021 05:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633091324; cv=none; d=google.com; s=arc-20160816; b=TQrLW4SUU/aQHHMjzdd7NXKt+FqpjWYHIh3DMhSK//oJQ0ZSPMB8JENUaHg6N6+6O1 CE8mIGciOvv9iVp85Jo1EiOZWunH9EzkYAGZ6NDc8M5ZrFV3pH8MM4QXxmTqUne42tpt IIo2/y2KernhvrIzpbkBfb+cfRpVIBOoJaS3yB5X7aW2MlkF/HfhzK/esgc0CTk5tOmy mYrx3bDtCIlsa+0ngzUuwZCSEVHKYHMMoM/vH+wtoUU/lN9PPlsIkwUIkozEneDtGlWx gcRWq9JAlEi60km8s4Aa5Tx8Jq+PYi61CP22G9JwZf7kyF/7HEwAiXYfq+/VWxEKtVOt dq/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:reply-to :from:subject:message-id; bh=xrs4tlIRnAZw2/2mPPxMme9OKLr+8AefG5STnsCzbfY=; b=mteViE2Sc3A044+BlEB77cEsr26iviNPy+pchtQ6N9WC8makO71Z1GFKDKswEoIPLY H76ZayiBO/SsewjVq4Q9g8B60Ug5Yp8y5FYKOxnaDV/r+6Fij+leL5v28nNc5rUHrYU0 VfzbwfEOOC9+yqUL3kUClgNeL4wG1YbGYxQqW32TB1BbD9taQ4VZWJuHm5zKVI60VBGg CGePnryZiIQspLAo9fpXej4R51mdsqMRhyZXBV5IFnR4EP7lTx4cIHJpDx/ZZnYi8ZEq K18qwS0trRptnP2UWW4HZl+x8EBC7otoVlhbnJIULpyt+VfLi1Ghz8e93XJ5sJh8W4z9 5+9w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si13386180ejc.6.2021.10.01.05.28.00; Fri, 01 Oct 2021 05:28:44 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353625AbhJAKkI (ORCPT + 99 others); Fri, 1 Oct 2021 06:40:08 -0400 Received: from mga17.intel.com ([192.55.52.151]:21683 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353615AbhJAKkH (ORCPT ); Fri, 1 Oct 2021 06:40:07 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10123"; a="205551172" X-IronPort-AV: E=Sophos;i="5.85,337,1624345200"; d="scan'208";a="205551172" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2021 03:38:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,337,1624345200"; d="scan'208";a="709724066" Received: from linux.intel.com ([10.54.29.200]) by fmsmga005.fm.intel.com with ESMTP; 01 Oct 2021 03:38:23 -0700 Received: from debox1-desk1.jf.intel.com (debox1-desk1.jf.intel.com [10.54.75.53]) by linux.intel.com (Postfix) with ESMTP id 1E93B580223; Fri, 1 Oct 2021 03:38:23 -0700 (PDT) Message-ID: Subject: Re: [PATCH 5/5] platform/x86: Add Intel Software Defined Silicon driver From: "David E. Box" Reply-To: david.e.box@linux.intel.com To: Greg KH Cc: lee.jones@linaro.org, hdegoede@redhat.com, mgross@linux.intel.com, bhelgaas@google.com, andriy.shevchenko@linux.intel.com, srinivas.pandruvada@intel.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-pci@vger.kernel.org Date: Fri, 01 Oct 2021 03:38:23 -0700 In-Reply-To: References: <20211001012815.1999501-1-david.e.box@linux.intel.com> <20211001012815.1999501-6-david.e.box@linux.intel.com> Organization: David E. Box Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2021-10-01 at 09:14 +0200, Greg KH wrote: > On Thu, Sep 30, 2021 at 06:28:15PM -0700, David E. Box wrote: > > +static int sdsi_device_open(struct inode *inode, struct file *file) > > +{ > > +       struct miscdevice *miscdev = file->private_data; > > + > > +       get_device(miscdev->this_device); > > Why do you think this is needed?  Shouldn't the misc core handle all of > this for you already? > > > + > > +       return 0; > > +} > > + > > +static int sdsi_device_release(struct inode *inode, struct file *file) > > +{ > > + > > +       struct miscdevice *miscdev = file->private_data; > > +       struct sdsi_priv *priv = to_sdsi_priv(miscdev); > > + > > +       if (priv->akc_owner == file) > > +               priv->akc_owner = NULL; > > Why is this needed? > > > + > > +       put_device(miscdev->this_device); > > I see this matches the open call, but if you do not have this in the > open call, is it needed here as well? > > > +       ret = devm_add_action_or_reset(priv->miscdev.this_device, sdsi_miscdev_remove, priv); > > +       if (ret) > > +               goto deregister_misc; > > I think this is all you need to clean up your device memory, not the > get/put device in open/release, right? It does clean up the memory, but it does so immediately after the device has been unregistered, even if a file is open. The get/put ensures that if files are open, the memory isn't cleaned up until the files are closed. I can show that this happens without the get/put, open() unbind device -> devm action called -> kfree(priv) ioctl() -> priv accessed but it doesn't blow up. I guess because the former location of priv is accessible by container_of on the miscdev. But that memory was freed right? David > > thanks, > > greg k-h