From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthieu CASTET Subject: Re: usb audio race at disconnect time Date: Thu, 18 Oct 2012 17:39:05 +0200 Message-ID: <50802299.9080004@parrot.com> References: <5076E327.5030503@parrot.com> <50783A5B.9090009@parrot.com> <507C4AD4.2090400@parrot.com> <507D84C9.9070405@parrot.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Takashi Iwai Cc: USB list , ALSA devel , Greg KH , Daniel Mack , Clemens Ladisch List-Id: alsa-devel@alsa-project.org Takashi Iwai a =C3=A9crit : > At Tue, 16 Oct 2012 18:01:13 +0200, > Matthieu CASTET wrote: >> Takashi Iwai a =C3=A9crit : >>> At Mon, 15 Oct 2012 19:41:40 +0200, >>> Matthieu CASTET wrote: >>>> Hi Takashi, >>>> >>>> But I believe I found other races in the alsa char device handling= =2E With the >>>> attached patch, if you disconnect the usb audio device between "ms= leep o" and >>>> "msleep o+", you will free the card resource (snd_card_do_free) an= d then use it [1]. >>>> >>>> I did in in snd_ctl_open, but the same thing could be done in snd_= pcm_open, ... >>> OK, we'd need a generic open/close protection. >>> For PCM, there is already a fix in my last patchset, so it should >>> work, but for other devices, the paths are still uncovered. >>> >> I don't think it will work for pcm : the begin of snd_pcm_open is no= t protected >> by any lock even with your patch >> In snd_open we release sound_mutex before calling file->f_op->open. >> >> The snd_lookup_minor_data and snd_card_file_add should be protected = by a lock. >> Attached a patch (pcm.crash) that help to trigger [1]. >=20 > Check out my latest patches in topic/usb-disconnect-fix branch. > It's been fixed there. >=20 Thanks, the first tests seems ok. We will do more strees test. Matthieu -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html