btrfs-progs: handle errors in get_inode_backref and fail in the caller

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2016-01-06 15:08:46 +01:00
parent f72a3f9f9f
commit b317ca97d3

View file

@ -952,6 +952,8 @@ static struct inode_backref *get_inode_backref(struct inode_record *rec,
}
backref = malloc(sizeof(*backref) + namelen + 1);
if (!backref)
return NULL;
memset(backref, 0, sizeof(*backref));
backref->dir = dir;
backref->namelen = namelen;
@ -972,6 +974,7 @@ static int add_inode_backref(struct cache_tree *inode_cache,
rec = get_inode_rec(inode_cache, ino, 1);
BUG_ON(IS_ERR(rec));
backref = get_inode_backref(rec, name, namelen, dir);
BUG_ON(!backref);
if (errors)
backref->errors |= errors;
if (itemtype == BTRFS_DIR_INDEX_KEY) {