[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZRqPP9xT9fqrZLQS@smile.fi.intel.com>
Date: Mon, 2 Oct 2023 12:37:03 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Michal Wilczynski <michal.wilczynski@...el.com>
Cc: linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
nvdimm@...ts.linux.dev, rafael.j.wysocki@...el.com,
lenb@...nel.org, dan.j.williams@...el.com,
vishal.l.verma@...el.com, ira.weiny@...el.com
Subject: Re: [PATCH v1 1/2] ACPI: NFIT: Fix memory leak, and local use of
devm_*()
On Tue, Sep 26, 2023 at 09:45:19PM +0300, 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'.
>
> Fix this by switching from devm_kcalloc() to kcalloc(), and adding
> proper rollback.
LGTM,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists