Fix segmentation fault when opening invalid file system
authorHubert Kario <kario@wit.edu.pl>
Sun, 19 Feb 2012 20:11:46 +0000 (21:11 +0100)
committerChris Mason <chris.mason@fusionio.com>
Tue, 3 Jul 2012 20:27:46 +0000 (16:27 -0400)
Signed-off-by: Hubert Kario <kario@wit.edu.pl>
btrfslabel.c

index da694e1..bf73802 100644 (file)
@@ -55,6 +55,8 @@ static void change_label_unmounted(char *dev, char *nLabel)
         * and as read-write.
         */
        root = open_ctree(dev, 0, 1);
+       if (!root) /* errors are printed by open_ctree() */
+         return;
 
        trans = btrfs_start_transaction(root, 1);
        strncpy(root->fs_info->super_copy.label, nLabel, BTRFS_LABEL_SIZE);