svn commit: r317440 - in stable/11/sbin/geom: class/part misc
Alan Somers
asomers at FreeBSD.org
Wed Apr 26 14:50:08 UTC 2017
Author: asomers
Date: Wed Apr 26 14:50:06 2017
New Revision: 317440
URL: https://svnweb.freebsd.org/changeset/base/317440
Log:
MFC r316530, r316535
r316530:
Fix clearing geom metadata if DIOCGSECTORSIZE fails
An unhandled error case would result in passing SIZE_MAX to malloc.
While I'm here, remove an unnecessary NULL check before free
Reported by: Coverity
CID: 1017793
Sponsored by: Spectra Logic Corp
r316535:
Fix memory leak in "gpart bootcode"
Also, annotate that gpart_issue never returns
Reported by: Coverity
CID: 1007105
Sponsored by: Spectra Logic Corp
Modified:
stable/11/sbin/geom/class/part/geom_part.c
stable/11/sbin/geom/misc/subr.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sbin/geom/class/part/geom_part.c
==============================================================================
--- stable/11/sbin/geom/class/part/geom_part.c Wed Apr 26 14:44:39 2017 (r317439)
+++ stable/11/sbin/geom/class/part/geom_part.c Wed Apr 26 14:50:06 2017 (r317440)
@@ -81,7 +81,7 @@ static int gpart_autofill(struct gctl_re
static int gpart_autofill_resize(struct gctl_req *);
static void gpart_bootcode(struct gctl_req *, unsigned int);
static void *gpart_bootfile_read(const char *, ssize_t *);
-static void gpart_issue(struct gctl_req *, unsigned int);
+static _Noreturn void gpart_issue(struct gctl_req *, unsigned int);
static void gpart_show(struct gctl_req *, unsigned int);
static void gpart_show_geom(struct ggeom *, const char *, int);
static int gpart_show_hasopt(struct gctl_req *, const char *, const char *);
@@ -1270,6 +1270,7 @@ gpart_bootcode(struct gctl_req *req, uns
gpart_issue(req, fl);
geom_deletetree(&mesh);
+ free(partcode);
}
static void
@@ -1290,7 +1291,7 @@ gpart_print_error(const char *errstr)
warnx("%s", errmsg);
}
-static void
+static _Noreturn void
gpart_issue(struct gctl_req *req, unsigned int fl __unused)
{
char buf[4096];
Modified: stable/11/sbin/geom/misc/subr.c
==============================================================================
--- stable/11/sbin/geom/misc/subr.c Wed Apr 26 14:44:39 2017 (r317439)
+++ stable/11/sbin/geom/misc/subr.c Wed Apr 26 14:50:06 2017 (r317440)
@@ -336,7 +336,7 @@ g_metadata_clear(const char *name, const
goto out;
}
sectorsize = g_sectorsize(fd);
- if (sectorsize == 0) {
+ if (sectorsize <= 0) {
error = errno;
goto out;
}
@@ -365,8 +365,7 @@ g_metadata_clear(const char *name, const
}
(void)g_flush(fd);
out:
- if (sector != NULL)
- free(sector);
+ free(sector);
g_close(fd);
return (error);
}
More information about the svn-src-stable-11
mailing list