Skip to content

Commit 0d9f7f3

Browse files
ukernelchrismason-xx
authored andcommitted
btrfs_inode_by_name return random value.
When inode is found, the return value is from the uninitialized variable 'ret'. -- Signed-off-by: Chris Mason <[email protected]>
1 parent 5708b95 commit 0d9f7f3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/btrfs/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,15 +847,16 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
847847
struct btrfs_dir_item *di;
848848
struct btrfs_path *path;
849849
struct btrfs_root *root = BTRFS_I(dir)->root;
850-
int ret;
850+
int ret = 0;
851851

852852
path = btrfs_alloc_path();
853853
BUG_ON(!path);
854854
di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name,
855855
namelen, 0);
856+
if (IS_ERR(di))
857+
ret = PTR_ERR(di);
856858
if (!di || IS_ERR(di)) {
857859
location->objectid = 0;
858-
ret = 0;
859860
goto out;
860861
}
861862
btrfs_dir_item_key_to_cpu(path->nodes[0], di, location);

0 commit comments

Comments
 (0)