]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: core: Mark some variables as __ro_after_init
authorLen Bao <len.bao@gmx.us>
Sun, 24 May 2026 16:29:13 +0000 (16:29 +0000)
committerTakashi Iwai <tiwai@suse.de>
Mon, 25 May 2026 07:31:40 +0000 (09:31 +0200)
Some variables in the 'ALSA/core' are initialized only during the init
phase in the '__init' functions and never changed. So, mark them as
__ro_after_init to reduce the attack surface.

Signed-off-by: Len Bao <len.bao@gmx.us>
Link: https://patch.msgid.link/20260524162914.47764-1-len.bao@gmx.us
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/hrtimer.c
sound/core/oss/pcm_oss.c
sound/core/rawmidi.c
sound/core/seq/oss/seq_oss_init.c
sound/core/seq/seq_dummy.c

index 9fcd1c03dc5b29578a4bf027a27f6adc1975b3e1..92c585f8eeb1094a80f9621d85d98964713a923d 100644 (file)
@@ -20,7 +20,7 @@ MODULE_LICENSE("GPL");
 MODULE_ALIAS("snd-timer-" __stringify(SNDRV_TIMER_GLOBAL_HRTIMER));
 
 #define NANO_SEC       1000000000UL    /* 10^9 in sec */
-static unsigned int resolution;
+static unsigned int resolution __ro_after_init;
 
 struct snd_hrtimer {
        struct snd_timer *timer;
index 746eaf93e1a57fb6d16a53c24c12510f71f70640..9826d9a0be6d314d3b662d4d99337161eb9689e8 100644 (file)
@@ -32,8 +32,8 @@
 
 #define OSS_ALSAEMULVER                _SIOR ('M', 249, int)
 
-static int dsp_map[SNDRV_CARDS];
-static int adsp_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
+static int dsp_map[SNDRV_CARDS] __ro_after_init;
+static int adsp_map[SNDRV_CARDS] __ro_after_init = {[0 ... (SNDRV_CARDS-1)] = 1};
 static bool nonblock_open = 1;
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>, Abramo Bagnara <abramo@alsa-project.org>");
index 3b1034a449386251f6d4494df3a48656076b55fe..4dfd9d53e6d3a2e7b0eebbd99a530b6add7da75b 100644 (file)
@@ -28,8 +28,8 @@ MODULE_DESCRIPTION("Midlevel RawMidi code for ALSA.");
 MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_SND_OSSEMUL
-static int midi_map[SNDRV_CARDS];
-static int amidi_map[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = 1};
+static int midi_map[SNDRV_CARDS] __ro_after_init;
+static int amidi_map[SNDRV_CARDS] __ro_after_init = {[0 ... (SNDRV_CARDS-1)] = 1};
 module_param_array(midi_map, int, NULL, 0444);
 MODULE_PARM_DESC(midi_map, "Raw MIDI device number assigned to 1st OSS device.");
 module_param_array(amidi_map, int, NULL, 0444);
index d3e6a8a8d823479f831254eb981d574714801adb..1aece46c8b064cfe88401035f0d963e9260ce09d 100644 (file)
@@ -27,8 +27,8 @@ static int maxqlen = SNDRV_SEQ_OSS_MAX_QLEN;
 module_param(maxqlen, int, 0444);
 MODULE_PARM_DESC(maxqlen, "maximum queue length");
 
-static int system_client = -1; /* ALSA sequencer client number */
-static int system_port = -1;
+static int system_client __ro_after_init = -1; /* ALSA sequencer client number */
+static int system_port __ro_after_init = -1;
 
 static int num_clients;
 static struct seq_oss_devinfo *client_table[SNDRV_SEQ_OSS_MAX_CLIENTS];
index af45f328ae99013a353478082eb46137ba9c5e39..3fe0853aace34512ef6aabf3bb20623dcc8b8a09 100644 (file)
@@ -71,7 +71,7 @@ struct snd_seq_dummy_port {
        int connect;
 };
 
-static int my_client = -1;
+static int my_client __ro_after_init = -1;
 
 /*
  * event input callback - just redirect events to subscribers