Plug a memory leak.

This commit is contained in:
Xin LI 2013-07-02 17:34:34 +00:00
parent a559a5a94f
commit 1bf9e66cbc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=252514

View file

@ -491,6 +491,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag) if (!qflag)
warnx("%s: Device already in use", warnx("%s: Device already in use",
vnodefile); vnodefile);
free(vnodefile);
return (NULL); return (NULL);
} }
error = run_cmd(&fd, "%s -a -t vnode -n -f %s", 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) { if (error) {
warnx("mdconfig (attach) error: file=%s", warnx("mdconfig (attach) error: file=%s",
vnodefile); vnodefile);
free(vnodefile);
return (NULL); return (NULL);
} }
sfd = fdopen(fd, "r"); sfd = fdopen(fd, "r");
@ -537,6 +539,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag) if (!qflag)
warnx("md%d on %s: Device already " warnx("md%d on %s: Device already "
"in use", mdunit, vnodefile); "in use", mdunit, vnodefile);
free(vnodefile);
return (NULL); return (NULL);
} }
error = run_cmd(NULL, "%s -a -t vnode -u %d -f %s", 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) { if (error) {
warnx("mdconfig (attach) error: " warnx("mdconfig (attach) error: "
"md%d on file=%s", mdunit, vnodefile); "md%d on file=%s", mdunit, vnodefile);
free(vnodefile);
return (NULL); return (NULL);
} }
} }
@ -557,6 +561,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag) if (!qflag)
warnx("md on %s: Device not found", warnx("md on %s: Device not found",
vnodefile); vnodefile);
free(vnodefile);
return (NULL); return (NULL);
} }
sfd = fdopen(fd, "r"); sfd = fdopen(fd, "r");
@ -599,6 +604,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
if (!qflag) if (!qflag)
warnx("md%d on %s: Device not found", warnx("md%d on %s: Device not found",
mdunit, vnodefile); mdunit, vnodefile);
free(vnodefile);
return (NULL); return (NULL);
} }
} }
@ -622,6 +628,7 @@ swap_on_off_md(const char *name, char *mntops, int doingall)
fclose(sfd); fclose(sfd);
if (fd != -1) if (fd != -1)
close(fd); close(fd);
free(vnodefile);
return (ret); return (ret);
} }