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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>
CC: Josef Bacik <jbacik@xxxxxx>
CC: David Sterba <dsterba@xxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux