btrfs: only free root_path if it was allocated from the heap

Noticed this while doing some snapshots in a chroot environment

btrfs receive can set root_path to either realmnt, which is passed in from the
command line, or to a heap allocated via find_mount_root  in do_receive.  We
should only free the later, not the former, as the former results in an invalid
pointer warning from glibc during free.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Neil Horman 2015-12-03 13:45:44 -05:00 committed by David Sterba
parent e3bd2d145f
commit 2cb9b4dbbd

View file

@ -1201,6 +1201,8 @@ out:
close(r->write_fd);
r->write_fd = -1;
}
if (r->root_path != realmnt)
free(r->root_path);
r->root_path = NULL;
r->dest_dir_path = NULL;