diff mbox

Btrfs-progs: Fix a segmentation fault in btrfstune when <device> is invalid.

Message ID 1353313470-25087-1-git-send-email-chenyang.fnst@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chen Yang Nov. 19, 2012, 8:24 a.m. UTC
When open_ctree(device, ...) failed, the return value should be checked.

Signed-off-by: Cheng Yang <chenyang.fnst@cn.fujitsu.com>
---
 btrfstune.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/btrfstune.c b/btrfstune.c
index 47830c5..07648d5 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -107,6 +107,8 @@  int main(int argc, char *argv[])
 	}
 
 	root = open_ctree(device, 0, 1);
+	if (!root)
+		return 1;
 
 	if (seeding_flag) {
 		ret = update_seeding_flag(root, seeding_value);