mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-25 07:32:22 +00:00
btrfs-progs: receive: fix a segfault when passing error pointer to free()
I noticed a segfault of 'btrfs receive'. $ gdb #0 process_clone (path=0x23829d0 "after.s1.txt", offset=0, len=2097152, clone_uuid=<optimized out>, clone_ctransid=<optimized out>, clone_path=0x2382920 "after.s1.txt", clone_offset=0, user=0x7ffe21985ba0) at cmds/receive.c:793 793 free(si->path); (gdb) p si $1 = (struct subvol_info *) 0xfffffffffffffffe 'si' was an error pointer value. Add the check to make sure we don't pass such pointer to free(). Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
1c414061ed
commit
1822b12564
@ -811,7 +811,7 @@ static int process_clone(const char *path, u64 offset, u64 len,
|
||||
}
|
||||
|
||||
out:
|
||||
if (si) {
|
||||
if (!IS_ERR_OR_NULL(si)) {
|
||||
free(si->path);
|
||||
free(si);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user