Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760246AbXHHIv6 (ORCPT ); Wed, 8 Aug 2007 04:51:58 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751123AbXHHIvs (ORCPT ); Wed, 8 Aug 2007 04:51:48 -0400 Received: from rv-out-0910.google.com ([209.85.198.184]:61598 "EHLO rv-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbXHHIvr (ORCPT ); Wed, 8 Aug 2007 04:51:47 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:cc:subject:message-id:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=ugl2cSFnKfJ0o8CMSd7+BJI0ZNbcNFhN5BKqUFmAQ9+PAuxKjWagED8+DlX5rjwqF7mB1M/R+jdhLB3Z62TnPKq11XbbMj4JxD+7zcjAOwioD6oQ+10fZJ/nfQI2zk1yiESVA6WVafeBGKS08Y/ORQc8GUv5Ph3p8LJM1vOGSeI= Date: Wed, 8 Aug 2007 17:51:33 +0900 From: Tejun Heo To: "Eric W. Biederman" Cc: Greg KH , linux-kernel@vger.kernel.org, satyam@infradead.org, cornelia.huck@de.ibm.com, stern@rowland.harvard.edu, Linux Containers , gregkh@suse.de Subject: Re: [PATCH 17/25] sysfs: Rewrite rename in terms of sysfs dirents Message-ID: <20070808085133.GI13674@htj.dyndns.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1652 Lines: 58 > int sysfs_rename_dir(struct kobject * kobj, const char *new_name) > { > - struct sysfs_dirent *sd; > + struct sysfs_dirent *sd = kobj->sd; > struct dentry *parent = NULL; > struct dentry *old_dentry = NULL, *new_dentry = NULL; > const char *dup_name = NULL; > @@ -863,42 +863,41 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name) > > mutex_lock(&sysfs_rename_mutex); > > + error = 0; > + if (strcmp(sd->s_name, new_name) == 0) > + goto out; /* nothing to rename */ > + > /* get the original dentry */ > old_dentry = sysfs_get_dentry(sd); > if (IS_ERR(old_dentry)) { > error = PTR_ERR(old_dentry); > + goto out; > } > > parent = old_dentry->d_parent; > > /* lock parent and get dentry for new name */ > mutex_lock(&parent->d_inode->i_mutex); > + mutex_lock(&sysfs_mutex); > > + error = -EEXIST; > + if (sysfs_find_dirent(sd->s_parent, new_name)) > goto out_unlock; > > + error = -ENOMEM; > + new_dentry = d_alloc_name(parent, new_name); > + if (!new_dentry) > goto out_unlock; > > /* rename kobject and sysfs_dirent */ > error = -ENOMEM; > new_name = dup_name = kstrdup(new_name, GFP_KERNEL); > if (!new_name) > + goto out_unlock; > > error = kobject_set_name(kobj, "%s", new_name); > if (error) > + goto out_unlock; > > mutex_lock(&sysfs_mutex); sysfs_mutex is being grabbed twice and unlocked twice later. -- tejun - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/