ALSA: bebob: fix memory leak for M-Audio FW1814 and ProjectMix I/O at error path
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Mon, 17 Sep 2018 08:25:24 +0000 (17:25 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Sep 2018 10:07:30 +0000 (03:07 -0700)
commit b1fbebd4164b3d170ad916dcd692cf843c9c065d upstream.

After allocating model-dependent data for M-Audio FW1814 and ProjectMix
I/O, ALSA bebob driver has memory leak at error path.

This commit releases the allocated data at the error path.

Fixes: 04a2c73c97eb('ALSA: bebob: delayed registration of sound card')
Cc: <stable@vger.kernel.org> # v4.7+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/firewire/bebob/bebob.c
sound/firewire/bebob/bebob_maudio.c

index 3469ac14c89c83d635d2dadb2e52af3119b70d6a..d0dfa822266b0ef4c5226f1ea89d42f869208ed9 100644 (file)
@@ -263,6 +263,8 @@ do_registration(struct work_struct *work)
 error:
        mutex_unlock(&devices_mutex);
        snd_bebob_stream_destroy_duplex(bebob);
+       kfree(bebob->maudio_special_quirk);
+       bebob->maudio_special_quirk = NULL;
        snd_card_free(bebob->card);
        dev_info(&bebob->unit->device,
                 "Sound card registration failed: %d\n", err);
index 07e5abdbceb59cec189726d79ee5d200d452e53b..c42088821ba8394de459f8d8e0c062cd3240769c 100644 (file)
@@ -290,10 +290,6 @@ snd_bebob_maudio_special_discover(struct snd_bebob *bebob, bool is1814)
                bebob->midi_output_ports = 2;
        }
 end:
-       if (err < 0) {
-               kfree(params);
-               bebob->maudio_special_quirk = NULL;
-       }
        mutex_unlock(&bebob->mutex);
        return err;
 }