Skip to contentSkip to conversation

ALSA: rawmidi: Fix NULL dereference at proc read

PATCH New Takashi Iwai 1 participant 1 message Sep 16, 2023 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: rawmidi: Fix NULL dereference at proc read

At the implementation of the optional proc fs in rawmidi, I forgot that rmidi->ops itself is optional and can be NULL.
Add the proper NULL check for avoiding the Oops.

Fixes fa030f666d24 ("ALSA: ump: Additional proc output")
Reported-and-tested-by Mark Hills <[email protected]>
---
 sound/core/rawmidi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/rawmidi.c +1 -1
index ba06484ac4aa..1431cb997808 100644
@@ -1770,7 +1770,7 @@ static void snd_rawmidi_proc_info_read(struct snd_info_entry *entry,
 	if (IS_ENABLED(CONFIG_SND_UMP))
 		snd_iprintf(buffer, "Type: %s\n",
 			    rawmidi_is_ump(rmidi) ? "UMP" : "Legacy");
-	if (rmidi->ops->proc_read)
+	if (rmidi->ops && rmidi->ops->proc_read)
 		rmidi->ops->proc_read(entry, buffer);
 	mutex_lock(&rmidi->open_mutex);
 	if (rmidi->info_flags & SNDRV_RAWMIDI_INFO_OUTPUT) {
Signature · 1 line
2.35.3