summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2017-05-30 22:33:24 +0000
committerasomers <asomers@FreeBSD.org>2017-05-30 22:33:24 +0000
commit7a08f3dd6c04e5c11c8eac359a4cacf9f8d582a4 (patch)
tree04a8e8e3acded0c993555159baadb6408062afd9 /sbin
parentdabb19cd6d8154465acf21269861a78f3af90c7b (diff)
downloadFreeBSD-src-7a08f3dd6c04e5c11c8eac359a4cacf9f8d582a4.zip
FreeBSD-src-7a08f3dd6c04e5c11c8eac359a4cacf9f8d582a4.tar.gz
MFC r316535:
Fix memory leak in "gpart bootcode" Also, annotate that gpart_issue never returns Reported by: Coverity CID: 1007105 Sponsored by: Spectra Logic Corp
Diffstat (limited to 'sbin')
-rw-r--r--sbin/geom/class/part/geom_part.c5
-rw-r--r--sbin/geom/misc/subr.c5
2 files changed, 5 insertions, 5 deletions
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index 14827f6..2353997 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -81,7 +81,7 @@ static int gpart_autofill(struct gctl_req *);
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 *);
@@ -1259,6 +1259,7 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
gpart_issue(req, fl);
geom_deletetree(&mesh);
+ free(partcode);
}
static void
@@ -1279,7 +1280,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];
diff --git a/sbin/geom/misc/subr.c b/sbin/geom/misc/subr.c
index f7b2764..cf0d9b0 100644
--- a/sbin/geom/misc/subr.c
+++ b/sbin/geom/misc/subr.c
@@ -336,7 +336,7 @@ g_metadata_clear(const char *name, const char *magic)
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 char *magic)
}
(void)g_flush(fd);
out:
- if (sector != NULL)
- free(sector);
+ free(sector);
g_close(fd);
return (error);
}
OpenPOWER on IntegriCloud