diff mbox series

ALSA: oxfw: fix memory leak of discovered stream formats at error path

Message ID 20180917082620.11574-1-o-takashi@sakamocchi.jp (mailing list archive)
State New, archived
Headers show
Series ALSA: oxfw: fix memory leak of discovered stream formats at error path | expand

Commit Message

Takashi Sakamoto Sept. 17, 2018, 8:26 a.m. UTC
After finishing discover of stream formats, ALSA OXFW driver has memory
leak of allocated memory object at error path.

This commit releases the memory object at the error path.

Fixes: 6c29230e2a5f ('ALSA: oxfw: delayed registration of sound card')
Cc: <stable@vger.kernel.org> # v4.7+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 sound/firewire/oxfw/oxfw.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Takashi Iwai Sept. 17, 2018, 8:13 p.m. UTC | #1
On Mon, 17 Sep 2018 10:26:20 +0200,
Takashi Sakamoto wrote:
> 
> After finishing discover of stream formats, ALSA OXFW driver has memory
> leak of allocated memory object at error path.
> 
> This commit releases the memory object at the error path.
> 
> Fixes: 6c29230e2a5f ('ALSA: oxfw: delayed registration of sound card')
> Cc: <stable@vger.kernel.org> # v4.7+
> Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

Applied, thanks.


Takashi
diff mbox series

Patch

diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
index 1e5b2c802635..63b3e1ce986e 100644
--- a/sound/firewire/oxfw/oxfw.c
+++ b/sound/firewire/oxfw/oxfw.c
@@ -207,6 +207,7 @@  static int detect_quirks(struct snd_oxfw *oxfw)
 static void do_registration(struct work_struct *work)
 {
 	struct snd_oxfw *oxfw = container_of(work, struct snd_oxfw, dwork.work);
+	int i;
 	int err;
 
 	if (oxfw->registered)
@@ -269,6 +270,12 @@  static void do_registration(struct work_struct *work)
 	snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
 	if (oxfw->has_output)
 		snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
+	for (i = 0; i < SND_OXFW_STREAM_FORMAT_ENTRIES; ++i) {
+		kfree(oxfw->tx_stream_formats[i]);
+		oxfw->tx_stream_formats[i] = NULL;
+		kfree(oxfw->rx_stream_formats[i]);
+		oxfw->rx_stream_formats[i] = NULL;
+	}
 	snd_card_free(oxfw->card);
 	dev_info(&oxfw->unit->device,
 		 "Sound card registration failed: %d\n", err);