mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chancel Liu <chancel.liu@oss.nxp.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Shenghao Ding <shenghao-ding@ti.com>, Kevin Lu <kevin-lu@ti.com>,
	Baojun Xu <baojun.xu@ti.com>, Sen Wang <sen@ti.com>,
	David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>
Cc: Charles Keepax <ckeepax@opensource.cirrus.com>,
	patches@opensource.cirrus.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 0/6] ASoC: codecs: Fix resource leaks on card re-bind
Date: Sun, 13 Sep 2026 19:15:25 +0900	[thread overview]
Message-ID: <20260913101531.2787654-1-chancel.liu@oss.nxp.com> (raw)

From: Chancel Liu <chancel.liu@nxp.com>

Several ASoC codec drivers set up per-device resources from their ASoC
component probe, but the associated cleanup is tied to the underlying bus
(I2C/SPI) device rather than being balanced per component probe. This is
fine for a plain probe/remove, but it breaks when the sound card is
unregistered and re-registered while the bus device stays bound (a card
re-bind): the component probe runs again while the previous bus-level
resources are still live.

Two kinds of resources are affected:

- Regulator disable notifiers (wm8962, wm8995, tlv320aic31xx,
  tlv320aic3x)
  The same notifier_block is re-registered on the
  still-registered regulator notifier chain, which triggers

    notifier callback ..._regulator_event_N already registered
    WARNING: ... at kernel/notifier.c:23 notifier_chain_register

  and corrupts the chain.

- Beep input devices (wm8962, cs42l52, cs42l56)
  A new input device is allocated and registered on every component
  probe while the free path only clears the pointer, leaking the
  previous input device and its sysfs/input node.

The two problems need opposite fixes: the notifiers are registered from
the component probe, so the registration is moved to the bus probe so it
runs once per bus bind; the beep device is freed from the component
remove path, so it is switched from devm_input_allocate_device() to
input_allocate_device() paired with an explicit
input_unregister_device() on that same free path.

Verified with wm8962. The remaining patches fix other codec drivers
following the same patterns.

Chancel Liu (6):
  ASoC: wm8962: Fix regulator notifier and beep leaks on card re-bind
  ASoC: wm8995: Register regulator notifiers from the bus probe
  ASoC: tlv320aic31xx: Register regulator notifier from the I2C probe
  ASoC: tlv320aic3x: Register regulator notifier from the bus probe
  ASoC: cs42l52: Fix beep input device leak on card re-bind
  ASoC: cs42l56: Fix beep input device leak on card re-bind

 sound/soc/codecs/cs42l52.c       |  9 ++++--
 sound/soc/codecs/cs42l56.c       |  9 ++++--
 sound/soc/codecs/tlv320aic31xx.c | 30 +++++++++---------
 sound/soc/codecs/tlv320aic3x.c   | 28 ++++++++---------
 sound/soc/codecs/wm8962.c        | 52 +++++++++++++++++---------------
 sound/soc/codecs/wm8995.c        | 41 ++++++++++++++++---------
 6 files changed, 96 insertions(+), 73 deletions(-)

--
2.50.1


             reply	other threads:[~2026-09-13 10:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13 10:15 Chancel Liu [this message]
2026-09-13 10:15 ` [PATCH 1/6] ASoC: wm8962: Fix regulator notifier and beep " Chancel Liu
2026-09-14 10:56   ` Charles Keepax
2026-09-13 10:15 ` [PATCH 2/6] ASoC: wm8995: Register regulator notifiers from the bus probe Chancel Liu
2026-09-14 12:49   ` Charles Keepax
2026-09-13 10:15 ` [PATCH 3/6] ASoC: tlv320aic31xx: Register regulator notifier from the I2C probe Chancel Liu
2026-09-13 10:15 ` [PATCH 4/6] ASoC: tlv320aic3x: Register regulator notifier from the bus probe Chancel Liu
2026-09-13 10:15 ` [PATCH 5/6] ASoC: cs42l52: Fix beep input device leak on card re-bind Chancel Liu
2026-09-14 12:51   ` Charles Keepax
2026-09-13 10:15 ` [PATCH 6/6] ASoC: cs42l56: " Chancel Liu
2026-09-14 12:52   ` Charles Keepax
2026-09-14 13:58 ` [PATCH 0/6] ASoC: codecs: Fix resource leaks " 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=20260913101531.2787654-1-chancel.liu@oss.nxp.com \
    --to=chancel.liu@oss.nxp.com \
    --cc=baojun.xu@ti.com \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=david.rhodes@cirrus.com \
    --cc=kevin-lu@ti.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=perex@perex.cz \
    --cc=rf@opensource.cirrus.com \
    --cc=sen@ti.com \
    --cc=shenghao-ding@ti.com \
    --cc=tiwai@suse.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

all inboxes | Powered by JetHome®