summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2020-01-14 21:47:58 +0000
committerBen Hutchings <ben@decadent.org.uk>2020-01-14 21:47:58 +0000
commit085bcee967542ff62f963d7a408ea0231dc5efd1 (patch)
treed87c16a54cedfb946c497628d44c5b458af9d962
parente5ea9dfa7965460285bd3528e5aed37b5a1527c9 (diff)
downloadlinux-stable-queue-085bcee967542ff62f963d7a408ea0231dc5efd1.tar.gz
Add fixes for line6
-rw-r--r--queue-3.16/alsa-line6-drop-superfluous-snd_device-for-pcm.patch128
-rw-r--r--queue-3.16/alsa-line6-fix-memory-leak-at-line6_init_pcm-error-path.patch53
-rw-r--r--queue-3.16/series2
3 files changed, 183 insertions, 0 deletions
diff --git a/queue-3.16/alsa-line6-drop-superfluous-snd_device-for-pcm.patch b/queue-3.16/alsa-line6-drop-superfluous-snd_device-for-pcm.patch
new file mode 100644
index 00000000..5b6b2d3f
--- /dev/null
+++ b/queue-3.16/alsa-line6-drop-superfluous-snd_device-for-pcm.patch
@@ -0,0 +1,128 @@
+From: Takashi Iwai <tiwai@suse.de>
+Date: Mon, 19 Jan 2015 14:41:57 +0100
+Subject: ALSA: line6: Drop superfluous snd_device for PCM
+
+commit b45a7c565473d29bd7e02ac8ca86232a24ca247f upstream.
+
+Instead of handling the card-specific resource in snd_device, attach
+it into pcm->private_data and release it directly in private_free.
+This simplifies the code and structure.
+
+Tested-by: Chris Rorvick <chris@rorvick.com>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+[bwh: Backported to 3.16 as dependency of commit 1bc8d18c75fe
+ "ALSA: line6: Fix memory leak at line6_init_pcm() error path"]
+ - Adjust filename, context]
+Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
+---
+ drivers/staging/line6/pcm.c | 53 ++++++++++++++++---------------------------
+ 1 file changed, 19 insertions(+), 34 deletions(-)
+
+--- a/drivers/staging/line6/pcm.c
++++ b/drivers/staging/line6/pcm.c
+@@ -345,24 +345,21 @@ static void line6_cleanup_pcm(struct snd
+ usb_free_urb(line6pcm->urb_audio_in[i]);
+ }
+ }
++ kfree(line6pcm);
+ }
+
+ /* create a PCM device */
+-static int snd_line6_new_pcm(struct snd_line6_pcm *line6pcm)
++static int snd_line6_new_pcm(struct usb_line6 *line6, struct snd_pcm **pcm_ret)
+ {
+ struct snd_pcm *pcm;
+ int err;
+
+- err = snd_pcm_new(line6pcm->line6->card,
+- (char *)line6pcm->line6->properties->name,
+- 0, 1, 1, &pcm);
++ err = snd_pcm_new(line6->card, (char *)line6->properties->name,
++ 0, 1, 1, pcm_ret);
+ if (err < 0)
+ return err;
+-
+- pcm->private_data = line6pcm;
+- pcm->private_free = line6_cleanup_pcm;
+- line6pcm->pcm = pcm;
+- strcpy(pcm->name, line6pcm->line6->properties->name);
++ pcm = *pcm_ret;
++ strcpy(pcm->name, line6->properties->name);
+
+ /* set operators */
+ snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
+@@ -374,13 +371,6 @@ static int snd_line6_new_pcm(struct snd_
+ snd_dma_continuous_data
+ (GFP_KERNEL), 64 * 1024,
+ 128 * 1024);
+-
+- return 0;
+-}
+-
+-/* PCM device destructor */
+-static int snd_line6_pcm_free(struct snd_device *device)
+-{
+ return 0;
+ }
+
+@@ -416,12 +406,9 @@ void line6_pcm_disconnect(struct snd_lin
+ int line6_init_pcm(struct usb_line6 *line6,
+ struct line6_pcm_properties *properties)
+ {
+- static struct snd_device_ops pcm_ops = {
+- .dev_free = snd_line6_pcm_free,
+- };
+-
+ int err;
+ int ep_read = 0, ep_write = 0;
++ struct snd_pcm *pcm;
+ struct snd_line6_pcm *line6pcm;
+
+ if (!(line6->properties->capabilities & LINE6_BIT_PCM))
+@@ -475,11 +462,16 @@ int line6_init_pcm(struct usb_line6 *lin
+ MISSING_CASE;
+ }
+
+- line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL);
++ err = snd_line6_new_pcm(line6, &pcm);
++ if (err < 0)
++ return err;
+
+- if (line6pcm == NULL)
++ line6pcm = kzalloc(sizeof(*line6pcm), GFP_KERNEL);
++ if (!line6pcm)
+ return -ENOMEM;
+
++ line6pcm->pcm = pcm;
++ line6pcm->properties = properties;
+ line6pcm->volume_playback[0] = line6pcm->volume_playback[1] = 255;
+ line6pcm->volume_monitor = 255;
+ line6pcm->line6 = line6;
+@@ -498,22 +490,15 @@ int line6_init_pcm(struct usb_line6 *lin
+ return -EINVAL;
+ }
+
+- line6pcm->properties = properties;
+- line6->line6pcm = line6pcm;
+-
+- /* PCM device: */
+- err = snd_device_new(line6->card, SNDRV_DEV_PCM, line6, &pcm_ops);
+- if (err < 0)
+- return err;
+-
+- err = snd_line6_new_pcm(line6pcm);
+- if (err < 0)
+- return err;
+-
+ 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;
diff --git a/queue-3.16/alsa-line6-fix-memory-leak-at-line6_init_pcm-error-path.patch b/queue-3.16/alsa-line6-fix-memory-leak-at-line6_init_pcm-error-path.patch
new file mode 100644
index 00000000..3b1180a9
--- /dev/null
+++ b/queue-3.16/alsa-line6-fix-memory-leak-at-line6_init_pcm-error-path.patch
@@ -0,0 +1,53 @@
+From: Takashi Iwai <tiwai@suse.de>
+Date: Wed, 21 Aug 2019 20:00:02 +0200
+Subject: 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>
+---
+ drivers/staging/line6/pcm.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/drivers/staging/line6/pcm.c
++++ b/drivers/staging/line6/pcm.c
+@@ -478,6 +478,15 @@ int line6_init_pcm(struct usb_line6 *lin
+ 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 *lin
+ 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;
diff --git a/queue-3.16/series b/queue-3.16/series
new file mode 100644
index 00000000..920bf64b
--- /dev/null
+++ b/queue-3.16/series
@@ -0,0 +1,2 @@
+alsa-line6-drop-superfluous-snd_device-for-pcm.patch
+alsa-line6-fix-memory-leak-at-line6_init_pcm-error-path.patch