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 <nhor...@tuxdriver.com>
CC: Josef Bacik <jba...@fb.com>
CC: David Sterba <dste...@suse.cz>
---
 cmds-receive.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index 3a84a3b..c25dc59 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -1201,7 +1201,9 @@ out:
                close(r->write_fd);
                r->write_fd = -1;
        }
-       free(r->root_path);
+
+       if (r->root_path != realmnt)
+               free(r->root_path);
        r->root_path = NULL;
        r->dest_dir_path = NULL;
        free(dest_dir_full_path);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to