Unionfs: run check_nd only if nd is valid in ->put_link
authorErez Zadok <ezk@cs.sunysb.edu>
Fri, 24 Sep 2010 06:21:08 +0000 (02:21 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2011 02:39:21 +0000 (22:39 -0400)
Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/debug.c
fs/unionfs/inode.c

index acc44bd70e207df5b45488c5e5a93afba99ddaa3..100d2c625c323d866857e6ee50ec659f84b373f2 100644 (file)
@@ -438,7 +438,6 @@ void __unionfs_check_nd(const struct nameidata *nd,
                        PRINT_CALLER(fname, fxn, line);
                        pr_debug(" CND1: lower_file of type %s\n",
                                 file->f_path.dentry->d_sb->s_type->name);
-                       BUG();
                }
        }
 }
index 062163a9e965eb5b72f8617698a50bf06fac6dbe..4c36f16b4d233ce6a599e8e29cf72ce5e5f5c474 100644 (file)
@@ -716,6 +716,7 @@ static void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,
                             void *cookie)
 {
        struct dentry *parent;
+       char *buf;
 
        unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_CHILD);
        parent = unionfs_lock_parent(dentry, UNIONFS_DMUTEX_PARENT);
@@ -726,8 +727,13 @@ static void unionfs_put_link(struct dentry *dentry, struct nameidata *nd,
                       "unionfs: put_link failed to revalidate dentry\n");
 
        unionfs_check_dentry(dentry);
+#if 0
+       /* XXX: can't run this check b/c this fxn can receive a poisoned 'nd' PTR */
        unionfs_check_nd(nd);
-       kfree(nd_get_link(nd));
+#endif
+       buf = nd_get_link(nd);
+       if (!IS_ERR(buf))
+               kfree(buf);
        unionfs_unlock_dentry(dentry);
        unionfs_unlock_parent(dentry, parent);
        unionfs_read_unlock(dentry->d_sb);