Allocated 'path' in check_fs_first_inode() is not checked and for
btrfs_search_slot() error, it will leak 'path'.
Fix it.
Resolves-Coverity-CID: 1374098
Resolves-Coverity-CID: 1374099
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
int ret;
path = btrfs_alloc_path();
+ if (!path)
+ return -ENOMEM;
key.objectid = 256;
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
- return ret;
+ goto out;
if (ret > 0) {
ret = 0;
err |= INODE_ITEM_MISSING;
err &= ~LAST_ITEM;
if (err && !ret)
ret = -EIO;
+out:
btrfs_free_path(path);
return ret;
}