|
Daniel P. Berrange |
511f6c |
From: Daniel Veillard <veillard@redhat.com>
|
|
Daniel P. Berrange |
511f6c |
Date: Mon, 16 Mar 2009 10:41:37 +0000 (+0000)
|
|
Daniel P. Berrange |
511f6c |
Subject: Avoid some potential FILE * leaks
|
|
Daniel P. Berrange |
511f6c |
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=39429bab2d55807698d9aed0112200ae532799b8
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
Avoid some potential FILE * leaks
|
|
Daniel P. Berrange |
511f6c |
* qemud/qemud.c src/cgroup.c src/uml_driver.c src/util.c: close
|
|
Daniel P. Berrange |
511f6c |
some potential FILE * leaks
|
|
Daniel P. Berrange |
511f6c |
Daniel
|
|
Daniel P. Berrange |
511f6c |
---
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
diff --git a/qemud/qemud.c b/qemud/qemud.c
|
|
Daniel P. Berrange |
511f6c |
index fd315fc..4f04355 100644
|
|
Daniel P. Berrange |
511f6c |
--- a/qemud/qemud.c
|
|
Daniel P. Berrange |
511f6c |
+++ b/qemud/qemud.c
|
|
Daniel P. Berrange |
511f6c |
@@ -488,7 +488,7 @@ static int qemudWritePidFile(const char *pidFile) {
|
|
Daniel P. Berrange |
511f6c |
if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
|
|
Daniel P. Berrange |
511f6c |
VIR_ERROR(_("Failed to write to pid file '%s' : %s"),
|
|
Daniel P. Berrange |
511f6c |
pidFile, virStrerror(errno, ebuf, sizeof ebuf));
|
|
Daniel P. Berrange |
511f6c |
- close(fd);
|
|
Daniel P. Berrange |
511f6c |
+ fclose(fh);
|
|
Daniel P. Berrange |
511f6c |
return -1;
|
|
Daniel P. Berrange |
511f6c |
}
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
diff --git a/src/cgroup.c b/src/cgroup.c
|
|
Daniel P. Berrange |
511f6c |
index 5af44bd..d1d44a2 100644
|
|
Daniel P. Berrange |
511f6c |
--- a/src/cgroup.c
|
|
Daniel P. Berrange |
511f6c |
+++ b/src/cgroup.c
|
|
Daniel P. Berrange |
511f6c |
@@ -57,7 +57,7 @@ void virCgroupFree(virCgroupPtr *group)
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
static virCgroupPtr virCgroupGetMount(const char *controller)
|
|
Daniel P. Berrange |
511f6c |
{
|
|
Daniel P. Berrange |
511f6c |
- FILE *mounts;
|
|
Daniel P. Berrange |
511f6c |
+ FILE *mounts = NULL;
|
|
Daniel P. Berrange |
511f6c |
struct mntent entry;
|
|
Daniel P. Berrange |
511f6c |
char buf[CGROUP_MAX_VAL];
|
|
Daniel P. Berrange |
511f6c |
virCgroupPtr root = NULL;
|
|
Daniel P. Berrange |
511f6c |
@@ -90,6 +90,8 @@ static virCgroupPtr virCgroupGetMount(const char *controller)
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
return root;
|
|
Daniel P. Berrange |
511f6c |
err:
|
|
Daniel P. Berrange |
511f6c |
+ if (mounts != NULL)
|
|
Daniel P. Berrange |
511f6c |
+ fclose(mounts);
|
|
Daniel P. Berrange |
511f6c |
virCgroupFree(&root);
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
return NULL;
|
|
Daniel P. Berrange |
511f6c |
diff --git a/src/uml_driver.c b/src/uml_driver.c
|
|
Daniel P. Berrange |
511f6c |
index 1dc7ccd..f7400f9 100644
|
|
Daniel P. Berrange |
511f6c |
--- a/src/uml_driver.c
|
|
Daniel P. Berrange |
511f6c |
+++ b/src/uml_driver.c
|
|
Daniel P. Berrange |
511f6c |
@@ -547,6 +547,7 @@ reopen:
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
if (fscanf(file, "%d", &vm->pid) != 1) {
|
|
Daniel P. Berrange |
511f6c |
errno = EINVAL;
|
|
Daniel P. Berrange |
511f6c |
+ fclose(file);
|
|
Daniel P. Berrange |
511f6c |
goto cleanup;
|
|
Daniel P. Berrange |
511f6c |
}
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
@@ -1040,6 +1041,7 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, int pid) {
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu", &usertime, &systime) != 2) {
|
|
Daniel P. Berrange |
511f6c |
umlDebug("not enough arg");
|
|
Daniel P. Berrange |
511f6c |
+ fclose(pidinfo);
|
|
Daniel P. Berrange |
511f6c |
return -1;
|
|
Daniel P. Berrange |
511f6c |
}
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
diff --git a/src/util.c b/src/util.c
|
|
Daniel P. Berrange |
511f6c |
index 9b74757..66ad9a4 100644
|
|
Daniel P. Berrange |
511f6c |
--- a/src/util.c
|
|
Daniel P. Berrange |
511f6c |
+++ b/src/util.c
|
|
Daniel P. Berrange |
511f6c |
@@ -1058,6 +1058,7 @@ int virFileReadPid(const char *dir,
|
|
Daniel P. Berrange |
511f6c |
|
|
Daniel P. Berrange |
511f6c |
if (fscanf(file, "%d", pid) != 1) {
|
|
Daniel P. Berrange |
511f6c |
rc = EINVAL;
|
|
Daniel P. Berrange |
511f6c |
+ fclose(file);
|
|
Daniel P. Berrange |
511f6c |
goto cleanup;
|
|
Daniel P. Berrange |
511f6c |
}
|
|
Daniel P. Berrange |
511f6c |
|