mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-17 10:16:53 +00:00
Btrfs-progs: seg fault in get_label_unmounted
btrfs f l / No valid Btrfs found on / Segmentation fault (core dumped) open_ctree can return NULL, we need to check that. Signed-off-by: Anand Jain <anand.jain@oracle.com>
This commit is contained in:
parent
8a25bb834b
commit
f4dfc8f6ed
10
btrfslabel.c
10
btrfslabel.c
@ -67,7 +67,7 @@ static void change_label_unmounted(char *dev, char *nLabel)
|
|||||||
close_ctree(root);
|
close_ctree(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_label_unmounted(char *dev)
|
int get_label_unmounted(char *dev)
|
||||||
{
|
{
|
||||||
struct btrfs_root *root;
|
struct btrfs_root *root;
|
||||||
|
|
||||||
@ -76,10 +76,14 @@ static void get_label_unmounted(char *dev)
|
|||||||
*/
|
*/
|
||||||
root = open_ctree(dev, 0, 0);
|
root = open_ctree(dev, 0, 0);
|
||||||
|
|
||||||
|
if(!root)
|
||||||
|
return -1;
|
||||||
|
|
||||||
fprintf(stdout, "%s\n", root->fs_info->super_copy.label);
|
fprintf(stdout, "%s\n", root->fs_info->super_copy.label);
|
||||||
|
|
||||||
/* Now we close it since we are done. */
|
/* Now we close it since we are done. */
|
||||||
close_ctree(root);
|
close_ctree(root);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_label(char *btrfs_dev)
|
int get_label(char *btrfs_dev)
|
||||||
@ -98,8 +102,8 @@ int get_label(char *btrfs_dev)
|
|||||||
fprintf(stderr, "FATAL: the filesystem has to be unmounted\n");
|
fprintf(stderr, "FATAL: the filesystem has to be unmounted\n");
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
get_label_unmounted(btrfs_dev);
|
ret = get_label_unmounted(btrfs_dev);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user