mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] aoa: Fix codec unregister handling
@ 2026-11-28  8:10 Sreeraj S Kurup
  0 siblings, 0 replies; only message in thread
From: Sreeraj S Kurup @ 2026-11-28  8:10 UTC (permalink / raw)
  To: johannes, perex, tiwai
  Cc: linuxppc-dev, linux-sound, linux-kernel, Sreeraj S Kurup

Fix aoa_codec_unregister() to use the codec's own fabric pointer
when removing a codec.

Previously, the function checked the global fabric pointer instead
of codec->fabric. This could call the fabric's remove_codec()
callback for a codec that was never attached to the fabric.

The function also called module_put() unconditionally, even when
no module reference had been acquired by attach_codec_to_fabric().
This could cause an incorrect module reference count.

Save codec->fabric before unregistering the codec, and call
exit(), remove_codec(), and module_put() only when the codec is
actually attached to a fabric.

This also prevents releasing the module reference a second time
when codec initialization has already failed and the attach path
has cleaned up.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/aoa/core/core.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/sound/aoa/core/core.c b/sound/aoa/core/core.c
index 99b032a4081f..41a3b79ca93a 100644
--- a/sound/aoa/core/core.c
+++ b/sound/aoa/core/core.c
@@ -71,13 +71,18 @@ EXPORT_SYMBOL_GPL(aoa_codec_register);
 
 void aoa_codec_unregister(struct aoa_codec *codec)
 {
+	struct aoa_fabric *codec_fabric = codec->fabric;
+
 	list_del(&codec->list);
-	if (codec->fabric && codec->exit)
-		codec->exit(codec);
-	if (fabric && fabric->remove_codec)
-		fabric->remove_codec(codec);
-	codec->fabric = NULL;
-	module_put(codec->owner);
+	if (codec_fabric) {
+		if (codec->exit)
+			codec->exit(codec);
+		if (codec_fabric->remove_codec)
+			codec_fabric->remove_codec(codec);
+
+		codec->fabric = NULL;
+		module_put(codec->owner);
+	}
 }
 EXPORT_SYMBOL_GPL(aoa_codec_unregister);
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-28  8:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-28  8:10 [PATCH] aoa: Fix codec unregister handling Sreeraj S Kurup

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®