From: Takashi Iwai Subject: Re: usb audio race at disconnect time Date: Tue, 16 Oct 2012 18:04:41 +0200 Message-ID: References: <5076E327.5030503@parrot.com> <50783A5B.9090009@parrot.com> <507C4AD4.2090400@parrot.com> <507D84C9.9070405@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: <507D84C9.9070405-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 Tue, 16 Oct 2012 18:01:13 +0200, Matthieu CASTET wrote: >=20 > 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, ... > >=20 > > 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. > >=20 > 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. >=20 > The snd_lookup_minor_data and snd_card_file_add should be protected b= y a lock. > Attached a patch (pcm.crash) that help to trigger [1]. Check out my latest patches in topic/usb-disconnect-fix branch. It's been fixed there. 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