aboutsummaryrefslogtreecommitdiff
path: root/nptl/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c b/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
index f25ccb213e..de8f54fb97 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_attr_setaffinity.c
@@ -34,14 +34,22 @@ pthread_attr_setaffinity_np (attr, cpuset)
assert (sizeof (*attr) >= sizeof (struct pthread_attr));
iattr = (struct pthread_attr *) attr;
- if (iattr->cpuset == NULL)
+ if (cpuset == NULL)
{
- iattr->cpuset = (cpu_set_t *) malloc (sizeof (cpu_set_t));
- if (iattr->cpuset == NULL)
- return ENOMEM;
+ free (iattr->cpuset);
+ iattr->cpuset = NULL;
}
+ else
+ {
+ if (iattr->cpuset == NULL)
+ {
+ iattr->cpuset = (cpu_set_t *) malloc (sizeof (cpu_set_t));
+ if (iattr->cpuset == NULL)
+ return ENOMEM;
+ }
- memcpy (iattr->cpuset, cpuset, sizeof (cpu_set_t));
+ memcpy (iattr->cpuset, cpuset, sizeof (cpu_set_t));
+ }
return 0;
}