From: Takashi Iwai Subject: Re: usb audio race at disconnect time Date: Mon, 29 Oct 2012 15:17:11 +0100 Message-ID: References: <5076E327.5030503@parrot.com> <50783A5B.9090009@parrot.com> <507C4AD4.2090400@parrot.com> <507D84C9.9070405@parrot.com> <50802299.9080004@parrot.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <50802299.9080004-ITF29qwbsa/QT0dZR+AlfA@public.gmane.org> Sender: linux-usb-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Matthieu CASTET Cc: USB list , ALSA devel , Greg KH , Daniel Mack , Clemens Ladisch List-Id: alsa-devel@alsa-project.org At Thu, 18 Oct 2012 17:39:05 +0200, Matthieu CASTET wrote: >=20 > 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 handli= ng. With the > >>>> attached patch, if you disconnect the usb audio device between "= msleep o" and > >>>> "msleep o+", you will free the card resource (snd_card_do_free) = and then use it [1]. > >>>> > >>>> I did in in snd_ctl_open, but the same thing could be done in sn= d_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 = not protected > >> by any lock even with your patch > >> In snd_open we release sound_mutex before calling file->f_op->open= =2E > >> > >> The snd_lookup_minor_data and snd_card_file_add should be protecte= d 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, >=20 > the first tests seems ok. > We will do more strees test. Do you have any good/bad test result? If no regression is seen, I'm going to apply the patches for 3.7-rc4. thanks, Takashi -- 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