summaryrefslogtreecommitdiffstats
path: root/sbin/swapon
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2013-07-02 17:34:34 +0000
committerdelphij <delphij@FreeBSD.org>2013-07-02 17:34:34 +0000
commit63b9166cda11513191c2994745dd279a2d264169 (patch)
tree1b9210e838e96cac68d9593a71e5a8970ce85a4e /sbin/swapon
parent1fafe35d7577b9b0ab13b4f1f8e13660d9305936 (diff)
downloadFreeBSD-src-63b9166cda11513191c2994745dd279a2d264169.zip
FreeBSD-src-63b9166cda11513191c2994745dd279a2d264169.tar.gz
Plug a memory leak.
Diffstat (limited to 'sbin/swapon')
-rw-r--r--sbin/swapon/swapon.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c
index b0b43d6..5dcb18d 100644
--- a/sbin/swapon/swapon.c
+++ b/sbin/swapon/swapon.c
@@ -491,6 +491,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag)
warnx("%s: Device already in use",
vnodefile);
+ free(vnodefile);
return (NULL);
}
error = run_cmd(&fd, "%s -a -t vnode -n -f %s",
@@ -498,6 +499,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (error) {
warnx("mdconfig (attach) error: file=%s",
vnodefile);
+ free(vnodefile);
return (NULL);
}
sfd = fdopen(fd, "r");
@@ -537,6 +539,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag)
warnx("md%d on %s: Device already "
"in use", mdunit, vnodefile);
+ free(vnodefile);
return (NULL);
}
error = run_cmd(NULL, "%s -a -t vnode -u %d -f %s",
@@ -544,6 +547,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (error) {
warnx("mdconfig (attach) error: "
"md%d on file=%s", mdunit, vnodefile);
+ free(vnodefile);
return (NULL);
}
}
@@ -557,6 +561,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag)
warnx("md on %s: Device not found",
vnodefile);
+ free(vnodefile);
return (NULL);
}
sfd = fdopen(fd, "r");
@@ -599,6 +604,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag)
warnx("md%d on %s: Device not found",
mdunit, vnodefile);
+ free(vnodefile);
return (NULL);
}
}
@@ -622,6 +628,7 @@ err:
fclose(sfd);
if (fd != -1)
close(fd);
+ free(vnodefile);
return (ret);
}
OpenPOWER on IntegriCloud