ALSA: seq/oss: Fix NULL dereference by auto-free
PATCH 1/1 ALSA: seq/oss: Fix NULL dereference by auto-free
The use of auto-cleanup in snd_seq_oss_midi_check_new_port() caused rather confusion, as it's keeping the assigned pointer with no_free_ptr() while it's referred in the left-hand side.
Since the auto-cleanup doesn't make the code easier to follow, revert the change in this function and manage the reference manually instead, and fix the regression by the previous change.
Reported-by [email protected]
Fixes 8b887676dc1f ("ALSA: seq: oss/midi: Cleanup with guard and auto-cleanup")
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/seq/oss/seq_oss_midi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/core/seq/oss/seq_oss_midi.c +5 -4
@@ -130,7 +130,7 @@ int snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo) {int i; - struct seq_oss_midi *mdev __free(seq_oss_midi) = NULL; +struct seq_oss_midi *mdev;/* the port must include generic midi */ if (! (pinfo->type &SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC ))
@@ -146,6 +146,7 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo) mdev =find_slot (pinfo->addr.client, pinfo->addr.port);if (mdev) {/* already exists */ +snd_use_lock_free (&mdev->use_lock);return 0 ; }
@@ -170,7 +171,7 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)/* create MIDI coder */ if (snd_midi_event_new (MAX_MIDI_EVENT_BUF , &mdev->coder) <0 ) {pr_err ("ALSA: seq_oss: can't malloc midi coder\n" ); -kfree (no_free_ptr (mdev)); +kfree (mdev);return -ENOMEM ; }/* OSS sequencer adds running status to all sequences */
@@ -187,13 +188,13 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)if (i >= max_midi_devs) {if (max_midi_devs >=SNDRV_SEQ_OSS_MAX_MIDI_DEVS ) {snd_midi_event_free (mdev->coder); -kfree (no_free_ptr (mdev)); +kfree (mdev);return -ENOMEM ; } max_midi_devs++; } mdev->seq_device = i; - midi_devs[mdev->seq_device] =no_free_ptr (mdev); + midi_devs[mdev->seq_device] = mdev;return 0 ; }
Signature · 1 line
2.50.1