Message ID | 1383779755-18228-6-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: > Close fd before we return on error paths. > > Resolves-Coverity-CID: 1125939 > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > utils.c | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/utils.c b/utils.c > index c11a7c2..c784345 100644 > --- a/utils.c > +++ b/utils.c > @@ -1905,10 +1905,12 @@ int test_dev_for_mkfs(char *file, int force_overwrite, char *estr) > if (fstat(fd, &st)) { > snprintf(estr, sz, "unable to stat %s: %s\n", file, > strerror(errno)); > + close(fd); > return 1; > } > if (!S_ISBLK(st.st_mode)) { > fprintf(stderr, "'%s' is not a block device\n", file); > + close(fd); > return 1; > } > close(fd); > -- 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 c11a7c2..c784345 100644 --- a/utils.c +++ b/utils.c @@ -1905,10 +1905,12 @@ int test_dev_for_mkfs(char *file, int force_overwrite, char *estr) if (fstat(fd, &st)) { snprintf(estr, sz, "unable to stat %s: %s\n", file, strerror(errno)); + close(fd); return 1; } if (!S_ISBLK(st.st_mode)) { fprintf(stderr, "'%s' is not a block device\n", file); + close(fd); return 1; } close(fd);
Close fd before we return on error paths. Resolves-Coverity-CID: 1125939 Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- utils.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)