]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
btrfs_inode_by_name return random value.
authorYan <yanzheng@21cn.com>
Thu, 25 Oct 2007 19:48:28 +0000 (15:48 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:03:57 +0000 (11:03 -0400)
When inode is found, the return value is from the uninitialized
variable 'ret'.

--

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/inode.c

index c07433072322c3b7fe91a89f1469d6d6c4900454..b74a831fab19cc511bee5d4dfbe19aecbad20d5a 100644 (file)
@@ -847,15 +847,16 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
        struct btrfs_dir_item *di;
        struct btrfs_path *path;
        struct btrfs_root *root = BTRFS_I(dir)->root;
-       int ret;
+       int ret = 0;
 
        path = btrfs_alloc_path();
        BUG_ON(!path);
        di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name,
                                    namelen, 0);
+       if (IS_ERR(di))
+               ret = PTR_ERR(di);
        if (!di || IS_ERR(di)) {
                location->objectid = 0;
-               ret = 0;
                goto out;
        }
        btrfs_dir_item_key_to_cpu(path->nodes[0], di, location);