Message ID | 1383779755-18228-14-git-send-email-sandeen@redhat.com (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
reviewed-by: Anand Jain <anand.jain@oracle.com> On 11/07/2013 07:15 AM, Eric Sandeen wrote: > 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> > --- > utils.c | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/utils.c b/utils.c > index 8471148..ecacc29 100644 > --- a/utils.c > +++ b/utils.c > @@ -1937,6 +1937,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; > @@ -1965,8 +1966,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); > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/utils.c b/utils.c index 8471148..ecacc29 100644 --- a/utils.c +++ b/utils.c @@ -1937,6 +1937,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; @@ -1965,8 +1966,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);
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> --- utils.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)