Skip to content

ASoC: codecs: Fix resource leaks on card re-bind

Chancel Liu linux-sound lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6ASoC: wm8962: Fix regulator notifier and beep leaks on card re-bindsound/soc/codecs/wm8962.c+28 -241 reply
2/6ASoC: wm8995: Register regulator notifiers from the bus probesound/soc/codecs/wm8995.c+27 -141 reply
3/6ASoC: tlv320aic31xx: Register regulator notifier from the I2C probesound/soc/codecs/tlv320aic31xx.c+14 -160 replies
4/6ASoC: tlv320aic3x: Register regulator notifier from the bus probesound/soc/codecs/tlv320aic3x.c+13 -150 replies
5/6ASoC: cs42l52: Fix beep input device leak on card re-bindsound/soc/codecs/cs42l52.c+7 -21 reply
6/6ASoC: cs42l56: Fix beep input device leak on card re-bindsound/soc/codecs/cs42l56.c+7 -21 reply

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchCharles Keepax
1/6R-b
2/6R-b
3/6
4/6
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/6] ASoC: codecs: Fix resource leaks on card re-bind

From: Chancel Liu <[email protected]>

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