From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 1/2] ALSA: usb: fix corrupted pointers due to interface setting change Date: Fri, 14 Aug 2015 17:57:15 +0200 Message-ID: References: <1439505753-3532-1-git-send-email-pierre-louis.bossart@linux.intel.com> <1439505753-3532-2-git-send-email-pierre-louis.bossart@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 9670E2657F9 for ; Fri, 14 Aug 2015 17:57:16 +0200 (CEST) In-Reply-To: <1439505753-3532-2-git-send-email-pierre-louis.bossart@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org 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;