Skip to contentSkip to conversation

ALSA: core: Validate device type for dynamic minors

PATCH In review Sreeraj S Kurup 2 participants 3 messages Nov 4 – Nov 5 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: core: Validate device type for dynamic minors

Reject unsupported device types when allocating dynamic minors.

This prevents invalid device types from being registered and avoids unnecessarily consuming available minor numbers.

Return -EINVAL for unsupported device types.

---
 sound/core/sound.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/core/sound.c +12 -0
index 24f40763a20c..32637c40df05 100644
@@ -184,6 +184,18 @@ static int snd_find_free_minor(int type, struct snd_card *card, int dev)
 	if (type == SNDRV_DEVICE_TYPE_TIMER)
 		return SNDRV_MINOR_TIMER;
 
+	switch (type) {
+	case SNDRV_DEVICE_TYPE_CONTROL:
+	case SNDRV_DEVICE_TYPE_HWDEP:
+	case SNDRV_DEVICE_TYPE_RAWMIDI:
+	case SNDRV_DEVICE_TYPE_PCM_PLAYBACK:
+	case SNDRV_DEVICE_TYPE_PCM_CAPTURE:
+	case SNDRV_DEVICE_TYPE_COMPRESS:
+		break;
+	default:
+		return -EINVAL;
+	}
+
 	for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor) {
 		/* skip static minors still used for module auto loading */
 		if (SNDRV_MINOR_DEVICE(minor) == SNDRV_MINOR_CONTROL)
Signature · 1 line
2.55.0
#1 lore raw
Quoted 9 lines · Sreeraj S Kurup

Reject unsupported device types when allocating dynamic minors.

This prevents invalid device types from being registered and avoids unnecessarily consuming available minor numbers.

Return -EINVAL for unsupported device types.

As it's no urgent fix, I applied to for-next branch now.

thanks,

Takashi