summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-11-06 17:15:52 -0600
committerChris Mason <chris.mason@fusionio.com>2013-11-07 16:10:41 -0500
commite11712a146c8a16c697a60ead980a9da68eaaddf (patch)
tree5d79ea59c678e93fc7ce3fb472a3de3fb3e0229e
parent18800f4a318704bb62039b6d2af50ee9bb077138 (diff)
btrfs-progs: check btrfs_scan_one_device in btrfs_scan_lblkid()
Even if it's "definitely" btrfs at this point, btrfs_scan_one_device could fail for other reasons. Check the return value, warn if it fails, and skip the device register. Resolves-Coverity-CID: 1125925 Signed-off-by: Eric Sandeen <sandeen@redhat.com> reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--utils.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils.c b/utils.c
index 3c74f690..704b371e 100644
--- a/utils.c
+++ b/utils.c
@@ -1960,6 +1960,7 @@ int test_skip_this_disk(char *path)
int btrfs_scan_lblkid(int update_kernel)
{
int fd = -1;
+ int ret;
u64 num_devices;
struct btrfs_fs_devices *tmp_devices;
blkid_dev_iterate iter = NULL;
@@ -1988,8 +1989,14 @@ int btrfs_scan_lblkid(int update_kernel)
printf("ERROR: could not open %s\n", path);
continue;
}
- btrfs_scan_one_device(fd, path, &tmp_devices,
+ ret = btrfs_scan_one_device(fd, path, &tmp_devices,
&num_devices, BTRFS_SUPER_INFO_OFFSET);
+ if (ret) {
+ printf("ERROR: could not scan %s\n", path);
+ close (fd);
+ continue;
+ }
+
close(fd);
if (update_kernel)
btrfs_register_one_device(path);