mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
To: perex@perex.cz, tiwai@suse.de
Cc: linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org,
	Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Subject: [PATCH] ALSA: Fix dynamic major number assignment
Date: Wed, 25 Nov 2026 07:30:09 +0000	[thread overview]
Message-ID: <20261125073009.3091-1-sreekuttan2156239@gmail.com> (raw)

When major is set to 0, register_chrdev() allocates
a major number and returns it.

Store the allocated major number and update snd_major
after successful registration.

This ensures ALSA uses the correct major number for
device registration and unregistration.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/core/sound.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/core/sound.c b/sound/core/sound.c
index 24f40763a20c..eaead62cf814 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -396,7 +396,6 @@ static int __init alsa_sound_init(void)
 {
 	int err;
 
-	snd_major = major;
 	snd_ecards_limit = cards_limit;
 
 	err = register_chrdev(major, "alsa", &snd_fops);
@@ -405,6 +404,10 @@ static int __init alsa_sound_init(void)
 		return err;
 	}
 
+	if (major == 0)
+		major = err;
+	snd_major = major;
+
 	err = snd_info_init();
 	if (err < 0) {
 		unregister_chrdev(major, "alsa");
-- 
2.55.0


             reply	other threads:[~2026-11-25  7:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  7:30 Sreeraj S Kurup [this message]
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:43   ` [PATCH v3] " Sreeraj S Kurup
2026-11-25  9:35   ` [PATCH v4] " Sreeraj S Kurup

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=20261125073009.3091-1-sreekuttan2156239@gmail.com \
    --to=sreekuttan2156239@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /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

all inboxes | Powered by JetHome®