linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
To: linux-fsdevel@vger.kernel.org
Cc: Erez Zadok <ezk@cs.sunysb.edu>,
	"Josef 'Jeff' Sipek" <jsipek@cs.sunysb.edu>
Subject: [PATCH 13/13] fs/unionfs/: Fix unlocking in error paths
Date: Sun,  4 Mar 2007 21:16:57 -0500	[thread overview]
Message-ID: <11730610193472-git-send-email-jsipek@cs.sunysb.edu> (raw)
In-Reply-To: <11730610174005-git-send-email-jsipek@cs.sunysb.edu>

From: Erez Zadok <ezk@cs.sunysb.edu>

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
 fs/unionfs/lookup.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c
index df929e9..967bb5b 100644
--- a/fs/unionfs/lookup.c
+++ b/fs/unionfs/lookup.c
@@ -84,6 +84,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
 	struct vfsmount *first_hidden_mnt = NULL;
 	int locked_parent = 0;
 	int locked_child = 0;
+	int allocated_new_info = 0;
 
 	int opaque;
 	char *whname = NULL;
@@ -101,9 +102,11 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, struct nameidata *n
 		BUG_ON(UNIONFS_D(dentry) != NULL);
 		locked_child = 1;
 	}
-	if (lookupmode != INTERPOSE_PARTIAL)
+	if (lookupmode != INTERPOSE_PARTIAL) {
 		if ((err = new_dentry_private_data(dentry)))
 			goto out;
+		allocated_new_info = 1;
+	}
 	/* must initialize dentry operations */
 	dentry->d_op = &unionfs_dops;
 
@@ -380,7 +383,7 @@ out:
 	if (locked_parent)
 		unionfs_unlock_dentry(parent_dentry);
 	dput(parent_dentry);
-	if (locked_child)
+	if (locked_child || (err && allocated_new_info))
 		unionfs_unlock_dentry(dentry);
 	return ERR_PTR(err);
 }
@@ -431,6 +434,7 @@ int new_dentry_private_data(struct dentry *dentry)
 	int newsize;
 	int oldsize = 0;
 	struct unionfs_dentry_info *info = UNIONFS_D(dentry);
+	int unlock_on_err = 0;
 
 	spin_lock(&dentry->d_lock);
 	if (!info) {
@@ -443,6 +447,7 @@ int new_dentry_private_data(struct dentry *dentry)
 
 		mutex_init(&info->lock);
 		mutex_lock(&info->lock);
+		unlock_on_err = 1;
 
 		info->lower_paths = NULL;
 	} else
@@ -482,6 +487,8 @@ int new_dentry_private_data(struct dentry *dentry)
 
 out_free:
 	kfree(info->lower_paths);
+	if (unlock_on_err)
+		mutex_unlock(&info->lock);
 
 out:
 	free_dentry_private_data(info);
-- 
1.5.0.2.260.g2eb065


      parent reply	other threads:[~2007-03-05  2:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-05  2:16 [GIT PULL -mm] Unionfs updates Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 01/13] fs/unionfs: Fix a memory leak & null pointer dereference Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 02/13] fs/unionfs/: Fix a memory leak in unionfs_read_super Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 03/13] fs/unionfs/: Don't grab dentry private data mutex in unionfs_d_release Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 04/13] fs/unionfs/: Several small cleanups in unionfs_interpose Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 05/13] fs/unionfs/: Rename unionfs_d_revalidate_wrap Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 06/13] fs/unionfs/: Remove alloc_filldir_node Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 07/13] fs/unionfs/: Use SEEK_{SET,CUR} instead of hardcoded values Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 08/13] fs/unionfs/: Check return value of d_path Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 09/13] fs/unionfs/: Miscellaneous coding style fixes Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 10/13] fs/unionfs/: Fix copyup_deleted_file dentry leak Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 11/13] fs/unionfs/: mntput in __cleanup_dentry Josef 'Jeff' Sipek
2007-03-05  2:16 ` [PATCH 12/13] fs/unionfs/: Fix dentry leak in copyup_named_dentry Josef 'Jeff' Sipek
2007-03-05  2:16 ` Josef 'Jeff' Sipek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11730610193472-git-send-email-jsipek@cs.sunysb.edu \
    --to=jsipek@cs.sunysb.edu \
    --cc=ezk@cs.sunysb.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).