All of lore.kernel.org
 help / color / mirror / Atom feed
From: phucduc.bui@gmail.com
To: Takashi Iwai <tiwai@suse.com>, Mark Brown <broonie@kernel.org>,
	Jaroslav Kysela <perex@perex.cz>,
	Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	bui duc phuc <phucduc.bui@gmail.com>
Subject: [PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card()
Date: Mon,  3 Aug 2026 17:27:39 +0700	[thread overview]
Message-ID: <20260803102739.55569-1-phucduc.bui@gmail.com> (raw)

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


             reply	other threads:[~2026-08-03 10:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 10:27 phucduc.bui [this message]
2026-08-03 10:50 ` [PATCH] ASoC: core: add snd_BUG_ON() check in devm_snd_soc_register_card() 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

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=20260803102739.55569-1-phucduc.bui@gmail.com \
    --to=phucduc.bui@gmail.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.