public inbox for driver-core@lists.linux.dev
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org, driver-core@lists.linux.dev,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>
Subject: Re: [PATCH v4 1/3] regcache: Move HW readback after cache initialisation
Date: Mon, 2 Mar 2026 17:09:20 +0200	[thread overview]
Message-ID: <aaWoIPZWIzPv1t5d@ashevche-desk.local> (raw)
In-Reply-To: <90f16d38-b698-4a84-b4f7-49597f353dfa@sirena.org.uk>

On Mon, Mar 02, 2026 at 02:49:49PM +0000, Mark Brown wrote:
> On Mon, Mar 02, 2026 at 10:56:55AM +0100, Andy Shevchenko wrote:

...

> > +	/*
> > +	 * Some devices such as PMICs don't have cache defaults,
> > +	 * we cope with this by reading back the HW registers and
> > +	 * crafting the cache defaults by hand.
> > +	 */
> > +	ret = regcache_hw_init(map, count);
> > +	if (ret)
> > +		goto err_exit;
> > +
> 
> We need to delete the free of reg_defaults from regcache_hw_init() when
> it fails, the error handling for err_exit also frees that so we'd end up
> with a double free.  Which is awfully error prone and part of what
> you're trying to fix here :/

Ah, looking again at it I see your point.

Indeed, in the error path of regcache_hw_init() we free the reg_defaults,
but the same is also done at err_free label of regcache_init().

NULLifying it at regcache_hw_init() doesn't sound like a good idea as
you pointed out as error prone case. I will think more about it, thanks
for catching this (I dunno why I missed that one)!

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2026-03-02 15:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02  9:56 [PATCH v4 0/3] regcache: Avoid accessing non-initialised cache Andy Shevchenko
2026-03-02  9:56 ` [PATCH v4 1/3] regcache: Move HW readback after cache initialisation Andy Shevchenko
2026-03-02 14:49   ` Mark Brown
2026-03-02 15:09     ` Andy Shevchenko [this message]
2026-03-02  9:56 ` [PATCH v4 2/3] regcache: Define iterator inside for-loop and align their types Andy Shevchenko
2026-03-02  9:56 ` [PATCH v4 3/3] regcache: Amend printf() specifiers when printing registers Andy Shevchenko
2026-03-03 11:20 ` [PATCH v4 0/3] regcache: Avoid accessing non-initialised cache Mark Brown

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=aaWoIPZWIzPv1t5d@ashevche-desk.local \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=dakr@kernel.org \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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