linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shuah Khan <shuahkh@osg.samsung.com>
To: Takashi Iwai <tiwai@suse.de>, Shuah Khan <shuahkhan@gmail.com>
Cc: alsa-devel@alsa-project.org, LKML <linux-kernel@vger.kernel.org>,
	Shuah Khan <shuahkh@osg.samsung.com>
Subject: Re: BUG: KASAN: use-after-free in snd_usb_audio_free
Date: Mon, 14 Nov 2016 09:55:54 -0700	[thread overview]
Message-ID: <c0ebdec6-717a-c5d8-56e4-9b9a5a9e111d@osg.samsung.com> (raw)
In-Reply-To: <s5hr36e2waq.wl-tiwai@suse.de>

On 11/14/2016 03:25 AM, Takashi Iwai wrote:
> On Sat, 12 Nov 2016 00:34:38 +0100,
> Shuah Khan wrote:
>>
>> Hi Takashi,
>>
>> I am seeing the following use-after-free error when I disconnect an
>> USB speaker. I saw this on 4.9-rc4 and 4.8.7. There might be race
>> condition between the disconnect and pcm close perhaps.
> 
> Thanks, this looks like a new discovery.
> Could you check whether the patch below works?
> 
> 
> Takashi
> 
> ---
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 9e5276d6dda0..2ddc034673a8 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -315,7 +315,8 @@ static int snd_usb_audio_free(struct snd_usb_audio *chip)
>  		snd_usb_endpoint_free(ep);
>  
>  	mutex_destroy(&chip->mutex);
> -	dev_set_drvdata(&chip->dev->dev, NULL);
> +	if (!atomic_read(&chip->shutdown))
> +		dev_set_drvdata(&chip->dev->dev, NULL);
>  	kfree(chip);
>  	return 0;
>  }
> 

Hi Takashi,

The patch fixed the problem on 4.9-rc4. Didn't get a chance
to test it on 4.8.7.

thanks,
-- Shuah

  reply	other threads:[~2016-11-14 16:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11 23:34 BUG: KASAN: use-after-free in snd_usb_audio_free Shuah Khan
2016-11-14 10:25 ` Takashi Iwai
2016-11-14 16:55   ` Shuah Khan [this message]
2016-11-14 21:06     ` 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=c0ebdec6-717a-c5d8-56e4-9b9a5a9e111d@osg.samsung.com \
    --to=shuahkh@osg.samsung.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shuahkhan@gmail.com \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).