The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card()
@ 2026-08-03 10:27 phucduc.bui
  2026-08-03 10:50 ` Cezary Rojewski
  0 siblings, 1 reply; 7+ messages in thread
From: phucduc.bui @ 2026-08-03 10:27 UTC (permalink / raw)
  To: Takashi Iwai, Mark Brown, Jaroslav Kysela, Liam Girdwood
  Cc: linux-sound, linux-kernel, bui duc phuc

From: bui duc phuc <phucduc.bui@gmail.com>

card is dereferenced immediately, so passing NULL results in a NULL
pointer dereference. A NULL dev is silently accepted, defeating the
documented automatic-unregistration semantics of this devm variant.

Add snd_BUG_ON() checks on both arguments to catch API misuse early.

Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
 sound/soc/soc-devres.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index 718165ba84ac..3e946196022a 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -59,6 +59,9 @@ EXPORT_SYMBOL_GPL(devm_snd_soc_register_component);
  */
 int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
 {
+	if (snd_BUG_ON(!dev || !card))
+		return -EINVAL;
+
 	card->devres_dev = dev;
 	return snd_soc_register_card(card);
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-04 14:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03 10:27 [PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card() phucduc.bui
2026-08-03 10:50 ` Cezary Rojewski
2026-08-03 11:58   ` Bui Duc Phuc
2026-08-03 20:42     ` Cezary Rojewski
2026-08-04  3:19       ` Bui Duc Phuc
2026-08-04 11:27         ` Cezary Rojewski
2026-08-04 14:02           ` Bui Duc Phuc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox