Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
From: Andreas Kemnade <andreas@kemnade.info>
To: Lee Jones <lee@kernel.org>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
	Kevin Hilman <khilman@baylibre.com>,
	Roger Quadros <rogerq@kernel.org>,
	Tony Lindgren <tony@atomide.com>, Kai Svahn <kai.svahn@nokia.com>,
	syed khasim <x0khasim@ti.com>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	linux-omap@vger.kernel.org, mfd@lists.linux.dev,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 13/27] mfd: twl-core: Clear twl_priv pointer on teardown and probe failure
Date: Wed, 28 Oct 2026 16:50:03 +0100	[thread overview]
Message-ID: <20261028165003.60d0c033@kemnade.info> (raw)
In-Reply-To: <20261027093306.2812695-14-lee@kernel.org>

On Tue, 27 Oct 2026 09:30:42 +0000
Lee Jones <lee@kernel.org> wrote:

> twl_probe() allocates the file-scope twl_priv state with devm_kzalloc()
> and checks for a non-NULL twl_priv at entry to reject multiple device
> instances.  However, twl_remove() and the early error paths in
> twl_probe() never reset twl_priv to NULL, a failure when adding MFD
> child devices bypasses twl_remove() by jumping to free instead of fail,
> and twl_remove() tears down the IRQ domain and dummy I2C clients before
> child devices are unregistered.  After devres frees the underlying
> memory on probe failure or unbind, twl_priv remains a dangling pointer,
> causing subsequent exported API calls to dereference freed memory and
> blocking future probe attempts with -EBUSY.
> 
> Unregister DT-populated and MFD child devices at the start of
> twl_remove(), ensure mfd_add_devices() failures unwind via fail, and
> reset twl_priv to NULL in twl_remove() and on probe error exit.
> 
> Fixes: 80a97ccd33be ("mfd: twl-core: Collect global variables behind one private structure (global)")
> Closes: https://sashiko.dev/#/bug/linux-73e82f84-94de-4d08-82a4-f22d42a1dedf
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>

Hmm, couldn't we use devm_add_action_or_reset() for resetting the
twl_priv pointer? Feels more clean for me.

Regards,
Andreas

  reply	other threads:[~2026-10-28 15:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  9:30 [PATCH v2 00/27] mfd: Assorted resource lifetime, teardown, and error-handling fixes Lee Jones
2026-10-27  9:30 ` [PATCH v2 12/27] mfd: twl-core: Clear pm_power_off callback in twl_remove() Lee Jones
2026-10-27  9:30 ` [PATCH v2 13/27] mfd: twl-core: Clear twl_priv pointer on teardown and probe failure Lee Jones
2026-10-28 15:50   ` Andreas Kemnade [this message]
2026-10-27  9:30 ` [PATCH v2 23/27] mfd: tps65217: Manage IRQ domain teardown via devres Lee Jones

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=20261028165003.60d0c033@kemnade.info \
    --to=andreas@kemnade.info \
    --cc=aaro.koskinen@iki.fi \
    --cc=kai.svahn@nokia.com \
    --cc=khilman@baylibre.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mfd@lists.linux.dev \
    --cc=peter.ujfalusi@ti.com \
    --cc=rogerq@kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=tony@atomide.com \
    --cc=x0khasim@ti.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