From: Karsten Wiese Subject: Re: [PATCH 1/2] New virtual device snd_disconnected rc3 Date: Thu, 5 Oct 2006 17:17:53 +0200 Message-ID: <200610051717.53608.annabellesgarden@yahoo.de> References: <200610051253.46779.annabellesgarden@yahoo.de> <200610051554.48027.annabellesgarden@yahoo.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@lists.sourceforge.net Errors-To: alsa-devel-bounces@lists.sourceforge.net To: Takashi Iwai Cc: alsa-devel@lists.sourceforge.net, Jaroslav Kysela List-Id: alsa-devel@alsa-project.org Am Donnerstag, 5. Oktober 2006 16:13 schrieb Takashi Iwai: > At Thu, 5 Oct 2006 15:54:47 +0200, > Karsten Wiese wrote: > > > > snd_disconnected_file, virtual device > > > > On response to "usb disconnect" an usb-soundcard manipulates > > that snd_card's file's f_ops to only allow release > > by calling this virtual device's > > void snd_disconnect_file(struct file *file). > > After release is actually called, the virtual device instance is freed. > > > > Signed-off-by: Karsten Wiese > > Thanks, the code looks better. > > > +void snd_disconnect_file(struct file *file) > > +{ > > + struct snd_disconnected_file *df; > > + df = kmalloc(sizeof(struct snd_disconnected_file), GFP_KERNEL); > > + if (df == NULL) > > + panic("Atomic allocation failed for snd_disconnected_file!"); > > The message doesn't match... > Some people prefer "if (!df)" although I myself don't mind at all. Me neither. I remember Al Viro preferring the "== NULL". > > > + > > + df->file = file; > > + df->f_op = file->f_op; > > + > > + mutex_lock(&mutex); > > + list_add(&df->list, &disconnected_files); > > + mutex_unlock(&mutex); > > + > > + fops_get(&snd_disconnect_f_ops); > > + file->f_op = &snd_disconnect_f_ops; > > + printk(KERN_INFO "%s rc3\n", __FUNCTION__); > > This will be removed in the final version, right? right. > > > +} > > My only concern is whether the release of the old f_op can be called > at the same time during snd_disconnect_file(). If this can happen, > it's racy and results in a memory leak. Uiuiui, good point! rc4 will merge with init.c. Karsten ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV