summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-08-21 20:00:02 +0200
committerBen Hutchings <ben@decadent.org.uk>2020-02-11 20:03:09 +0000
commit11de33d23baa0c9168e6e8e34bb4909de08291aa (patch)
tree71df7f7bf3156cce7cf6519b931d4446e8b3c96e
parent1f36225d6fe815cb0a746f5018e4c9b832a2e8d3 (diff)
downloadlinux-stable-11de33d23baa0c9168e6e8e34bb4909de08291aa.tar.gz
linux-stable-11de33d23baa0c9168e6e8e34bb4909de08291aa.tar.bz2
linux-stable-11de33d23baa0c9168e6e8e34bb4909de08291aa.zip
ALSA: line6: Fix memory leak at line6_init_pcm() error path
commit 1bc8d18c75fef3b478dbdfef722aae09e2a9fde7 upstream. I forgot to release the allocated object at the early error path in line6_init_pcm(). For addressing it, slightly shuffle the code so that the PCM destructor (pcm->private_free) is assigned properly before all error paths. Fixes: 3450121997ce ("ALSA: line6: Fix write on zero-sized buffer") Signed-off-by: Takashi Iwai <tiwai@suse.de> [bwh: Backported to 3.16: adjust filename, context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--drivers/staging/line6/pcm.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index 3bddb2ce570b..2c74df0b46b6 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -478,6 +478,15 @@ int line6_init_pcm(struct usb_line6 *line6,
line6pcm->ep_audio_read = ep_read;
line6pcm->ep_audio_write = ep_write;
+ spin_lock_init(&line6pcm->lock_audio_out);
+ spin_lock_init(&line6pcm->lock_audio_in);
+ spin_lock_init(&line6pcm->lock_trigger);
+
+ line6->line6pcm = line6pcm;
+
+ pcm->private_data = line6pcm;
+ pcm->private_free = line6_cleanup_pcm;
+
/* Read and write buffers are sized identically, so choose minimum */
line6pcm->max_packet_size = min(
usb_maxpacket(line6->usbdev,
@@ -490,15 +499,6 @@ int line6_init_pcm(struct usb_line6 *line6,
return -EINVAL;
}
- spin_lock_init(&line6pcm->lock_audio_out);
- spin_lock_init(&line6pcm->lock_audio_in);
- spin_lock_init(&line6pcm->lock_trigger);
-
- line6->line6pcm = line6pcm;
-
- pcm->private_data = line6pcm;
- pcm->private_free = line6_cleanup_pcm;
-
err = line6_create_audio_out_urbs(line6pcm);
if (err < 0)
return err;