NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Michal Wilczynski <michal.wilczynski@intel.com>,
	<linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<nvdimm@lists.linux.dev>
Cc: <rafael.j.wysocki@intel.com>, <andriy.shevchenko@intel.com>,
	<lenb@kernel.org>, <dan.j.williams@intel.com>,
	<vishal.l.verma@intel.com>, <ira.weiny@intel.com>,
	Michal Wilczynski <michal.wilczynski@intel.com>,
	"Andy Shevchenko" <andy.shevchenko@gmail.com>
Subject: RE: [PATCH v1 1/2] ACPI: NFIT: Fix memory leak, and local use of devm_*()
Date: Thu, 12 Oct 2023 16:40:46 -0700	[thread overview]
Message-ID: <652883fe10d38_780ef29459@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20230926184520.2239723-2-michal.wilczynski@intel.com>

Michal Wilczynski wrote:
> devm_*() family of functions purpose is managing memory attached to a
> device. So in general it should only be used for allocations that should
> last for the whole lifecycle of the device. This is not the case for
> acpi_nfit_init_interleave_set(). There are two allocations that are only
> used locally in this function. What's more - if the function exits on
> error path memory is never freed. It's still attached to dev and would
> be freed on device detach, so this leak could be called a 'local leak'.

This analysis is incorrect devm cleans up on driver ->probe() failure in
addition to ->remove(), and these error returns result in ->probe()
failures. No leak, i.e. this is not a fix.

The conversion to modern probe is ok if you want to resubmit that one
without this intervening change.

  parent reply	other threads:[~2023-10-12 23:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26 18:45 [PATCH v1 0/2] Fix memory leak and move to modern scope based rollback Michal Wilczynski
2023-09-26 18:45 ` [PATCH v1 1/2] ACPI: NFIT: Fix memory leak, and local use of devm_*() Michal Wilczynski
2023-09-26 18:52   ` Dave Jiang
2023-10-02  9:37   ` Andy Shevchenko
2023-10-12 23:40   ` Dan Williams [this message]
2023-09-26 18:45 ` [PATCH v1 2/2] ACPI: NFIT: Use modern scope based rollback Michal Wilczynski
2023-09-26 18:50   ` Dave Jiang
2023-10-02  9:38   ` Andy Shevchenko
2023-10-11 14:14 ` [PATCH v1 0/2] Fix memory leak and move to " Wilczynski, Michal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=652883fe10d38_780ef29459@dwillia2-xfh.jf.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=ira.weiny@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.wilczynski@intel.com \
    --cc=nvdimm@lists.linux.dev \
    --cc=rafael.j.wysocki@intel.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).