All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 1/2] ALSA: usb: fix corrupted pointers due to interface setting change
Date: Fri, 14 Aug 2015 17:57:15 +0200	[thread overview]
Message-ID: <s5hlhddsw10.wl-tiwai@suse.de> (raw)
In-Reply-To: <1439505753-3532-2-git-send-email-pierre-louis.bossart@linux.intel.com>

On Fri, 14 Aug 2015 00:42:32 +0200,
Pierre-Louis Bossart wrote:
> 
> --- a/sound/usb/pcm.c
> +++ b/sound/usb/pcm.c
> @@ -395,6 +395,19 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
>  	if (err < 0)
>  		return err;
>  
> +	if ((is_playback && (attr != USB_ENDPOINT_SYNC_ASYNC)) ||
> +		(!is_playback && (attr != USB_ENDPOINT_SYNC_ADAPTIVE))) {
> +
> +		/*
> +		 * Clean-up subs pointers to make sure sync_endpoint is never
> +		 * configured. This is needed in case of a transition between
> +		 * alternate settings using different synchronization modes
> +		 * where the previous sync_endpoint may no longer be valid.
> +		 */
> +		subs->sync_endpoint = NULL;
> +		subs->data_endpoint->sync_master = NULL;
> +	}

I think this initialization can be put unconditionally on top, not in
a separate like below, as this is just overlooked leaks.
The comment can be better in more details, of course.


Takashi

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index b4ef410e5a98..0d935369d641 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -391,6 +391,10 @@ static int set_sync_endpoint(struct snd_usb_substream *subs,
 	 */
 	attr = fmt->ep_attr & USB_ENDPOINT_SYNCTYPE;
 
+	/* Clean-up subs sync and master pointers at first */
+	subs->sync_endpoint = NULL;
+	subs->data_endpoint->sync_master = NULL;
+
 	err = set_sync_ep_implicit_fb_quirk(subs, dev, altsd, attr);
 	if (err < 0)
 		return err;

  parent reply	other threads:[~2015-08-14 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-13 22:42 [PATCH 0/2] USB audio fixes Pierre-Louis Bossart
2015-08-13 22:42 ` [PATCH 1/2] ALSA: usb: fix corrupted pointers due to interface setting change Pierre-Louis Bossart
2015-08-14 15:03   ` Takashi Iwai
2015-08-14 15:28     ` Takashi Iwai
2015-08-14 15:39       ` Pierre-Louis Bossart
2015-08-14 15:47         ` Takashi Iwai
2015-08-14 15:54           ` Takashi Iwai
2015-08-14 15:57   ` Takashi Iwai [this message]
2015-08-14 16:05     ` Pierre-Louis Bossart
2015-08-13 22:42 ` [PATCH 2/2] ALSA: usb: handle descriptor with SYNC_NONE illegal value Pierre-Louis Bossart
2015-08-14 16:03   ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hlhddsw10.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.