Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v3] ALSA: core: Reject zero major number
Date: Wed, 25 Nov 2026 08:52:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-232953@kernel.org> (raw)
In-Reply-To: <20261125084324.4151-1-sreekuttan2156239@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ALSA: core: using snd_ecards_limit for cards_limit breaks
  snd_request_card()
--

commit 09efa67fd5336064a9c9600571b9d55c3d75ea0a
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

ALSA: core: Reject zero major number

This commit rejects a zero major number in alsa_sound_init() and replaces
the static major and cards_limit variables with snd_major and
snd_ecards_limit via module_param_named().

> diff --git a/sound/core/sound.c b/sound/core/sound.c
> index ba226aa7affd3..746a5e254cbb8 100644
> --- a/sound/core/sound.c
> +++ b/sound/core/sound.c
> @@ -18,28 +18,25 @@
>  #include <linux/kmod.h>
>  #include <linux/mutex.h>
>  
> -static int major = CONFIG_SND_MAJOR;
> -int snd_major;
> +int snd_major = CONFIG_SND_MAJOR;
>  EXPORT_SYMBOL(snd_major);
>  
> -static int cards_limit = 1;
> +/* this one holds the actual max. card number currently available.
> + * as default, it's identical with cards_limit option.  when more
> + * modules are loaded manually, this limit number increases, too.
> + */
> +int snd_ecards_limit = 1;
> +EXPORT_SYMBOL(snd_ecards_limit);
>  
>  MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
>  MODULE_DESCRIPTION("Advanced Linux Sound Architecture driver for soundcards.");
>  MODULE_LICENSE("GPL");
> -module_param(major, int, 0444);
> +module_param_named(major, snd_major, int, 0444);
>  MODULE_PARM_DESC(major, "Major # for sound driver.");
> -module_param(cards_limit, int, 0444);
> +module_param_named(cards_limit, snd_ecards_limit, int, 0444);
>  MODULE_PARM_DESC(cards_limit, "Count of auto-loadable soundcards.");
>  MODULE_ALIAS_CHARDEV_MAJOR(CONFIG_SND_MAJOR);
>  
> -/* this one holds the actual max. card number currently available.
> - * as default, it's identical with cards_limit option.  when more
> - * modules are loaded manually, this limit number increases, too.
> - */
> -int snd_ecards_limit;
> -EXPORT_SYMBOL(snd_ecards_limit);
> -
>  #ifdef CONFIG_SND_DEBUG
>  struct dentry *sound_debugfs_root;
>  EXPORT_SYMBOL_GPL(sound_debugfs_root);
> @@ -61,7 +58,7 @@ void snd_request_card(int card)
>  {
>  	if (snd_card_locked(card))
>  		return;
> -	if (card < 0 || card >= cards_limit)
> +	if (card < 0 || card >= snd_ecards_limit)
>  		return;
>  	request_module("snd-card-%i", card);
>  }

[Severity: Medium]
Does replacing cards_limit with snd_ecards_limit raise the auto-load limit
at runtime and mutate the cards_limit module parameter?

snd_card_init() increases snd_ecards_limit whenever a card is registered
at an index at or above it:

sound/core/init.c:snd_card_init() {
	...
			if (idx >= snd_ecards_limit)
				snd_ecards_limit = idx + 1; /* increase the limit */
	...
}

Once a second card or a card with an explicit index >= cards_limit is
registered, snd_ecards_limit grows to idx + 1 and is never lowered on
disconnect.  snd_request_card() will then invoke
request_module("snd-card-%i", card) for unoccupied or disconnected card
slots above the configured cards_limit, and
/sys/module/snd/parameters/cards_limit will report the mutated runtime
high-water mark instead of the configured limit.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125084324.4151-1-sreekuttan2156239@gmail.com?part=1

      reply	other threads:[~2026-11-25  8:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  7:30 [PATCH] ALSA: Fix dynamic major number assignment Sreeraj S Kurup
2026-11-25  7:41 ` Takashi Iwai
2026-11-25  8:24   ` Sreeraj S Kurup
2026-11-25  8:30   ` [PATCH v2] ALSA: core: Reject zero major number Sreeraj S Kurup
2026-11-25  8:38     ` sashiko-bot
2026-11-25  8:43   ` [PATCH v3] " Sreeraj S Kurup
2026-11-25  8:52     ` sashiko-bot [this message]

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=sashiko-outbox-232953@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sreekuttan2156239@gmail.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