btrfs-progs: send: properly handle an ERR_PTR in find_good_parent
Pointer returned from get_parent needs additional handling otherwise we could return an error and then try to free it. Reset the pointer when the error occurs so the cleanup is always done on a valid pointer. Issue: #423 Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5004a7de0a
commit
433321ee8f
|
@ -108,6 +108,7 @@ static int find_good_parent(struct btrfs_send *sctx, u64 root_id, u64 *found)
|
|||
ret = -ENOENT;
|
||||
else
|
||||
ret = PTR_ERR(parent);
|
||||
parent = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -142,6 +143,7 @@ static int find_good_parent(struct btrfs_send *sctx, u64 root_id, u64 *found)
|
|||
ret = -ENOENT;
|
||||
else
|
||||
ret = PTR_ERR(parent2);
|
||||
parent2 = NULL;
|
||||
goto out;
|
||||
}
|
||||
tmp = parent2->ctransid - parent->ctransid;
|
||||
|
|
Loading…
Reference in New Issue