Skip to content

Commit

Permalink
ALSA: line6: Fix memory leak at line6_init_pcm() error path
Browse files Browse the repository at this point in the history
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: 3450121 ("ALSA: line6: Fix write on zero-sized buffer")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Aug 21, 2019
1 parent 6de3c9e commit 1bc8d18
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sound/usb/line6/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,15 @@ int line6_init_pcm(struct usb_line6 *line6,
line6pcm->volume_monitor = 255;
line6pcm->line6 = line6;

spin_lock_init(&line6pcm->out.lock);
spin_lock_init(&line6pcm->in.lock);
line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;

line6->line6pcm = line6pcm;

pcm->private_data = line6pcm;
pcm->private_free = line6_cleanup_pcm;

line6pcm->max_packet_size_in =
usb_maxpacket(line6->usbdev,
usb_rcvisocpipe(line6->usbdev, ep_read), 0);
Expand All @@ -562,15 +571,6 @@ int line6_init_pcm(struct usb_line6 *line6,
return -EINVAL;
}

spin_lock_init(&line6pcm->out.lock);
spin_lock_init(&line6pcm->in.lock);
line6pcm->impulse_period = LINE6_IMPULSE_DEFAULT_PERIOD;

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;
Expand Down

0 comments on commit 1bc8d18

Please sign in to comment.