aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-08-01 19:14:49 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-08-01 19:14:49 -0300
commitf09bae5082b415f38f95e12d4e9bafbd0d9f2908 (patch)
tree0b449d5f35bd37817fddb207a933a35f9b9f8cdf
parent76269f0df6224c1d9a9183a7f4fceaa16d5ca398 (diff)
downloadpython-schedutils-f09bae5082b415f38f95e12d4e9bafbd0d9f2908.tar.gz
Fix leak on setaffinity error path
If sched_setaffinity failed the cpus variable was not being freed. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--python-schedutils/schedutils.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/python-schedutils/schedutils.c b/python-schedutils/schedutils.c
index dfc7cb5..fd93565 100644
--- a/python-schedutils/schedutils.c
+++ b/python-schedutils/schedutils.c
@@ -182,11 +182,13 @@ static PyObject *set_affinity(PyObject *self __unused, PyObject *args)
CPU_SET_S(cpu, cpusetsize, cpus);
}
- if (sched_setaffinity(pid, sizeof(cpus), cpus) < 0) {
+ i = sched_setaffinity(pid, sizeof(cpus), cpus);
+ CPU_FREE(cpus);
+
+ if (i < 0) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
- CPU_FREE(cpus);
out:
Py_INCREF(Py_None);
return Py_None;