forked from pool/libcpuset
In referenced bnc, the user had too many files open, which led to an unhandled failure on the way to cpuset_equal_placement(), where it happily segfaulted. Handle errors instead of simply ignoring them. OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libcpuset?expand=0&rev=16
90 lines
1.9 KiB
Diff
90 lines
1.9 KiB
Diff
Subject: Robustify cpuset_pin(), cpuset_size() and cpuset_where() error handling
|
|
From: Mike Galbraith <mgalbraith@suse.de>
|
|
Date: Fri May 20 08:54:25 CEST 2016
|
|
References: bnc#978841
|
|
|
|
In referenced bnc, the user had too many files open, which led to an
|
|
unhandled failure on the way to cpuset_equal_placement(), where it
|
|
segfaulted. Handle errors instead of simply ignoring them:
|
|
|
|
Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
|
|
---
|
|
libcpuset.c | 30 ++++++++++++++++++++++++++----
|
|
1 file changed, 26 insertions(+), 4 deletions(-)
|
|
|
|
--- a/libcpuset.c
|
|
+++ b/libcpuset.c
|
|
@@ -3615,18 +3615,24 @@ int cpuset_pin(int relcpu)
|
|
return -1;
|
|
|
|
do {
|
|
+ r = -1;
|
|
cpuset_free_placement(plc1);
|
|
plc1 = cpuset_get_placement(0);
|
|
+ if (!plc1)
|
|
+ break;
|
|
|
|
- r = 0;
|
|
if (cpuset_unpin() < 0)
|
|
- r = -1;
|
|
+ break;
|
|
+
|
|
cpu = cpuset_p_rel_to_sys_cpu(0, relcpu);
|
|
- if (cpuset_cpubind(cpu) < 0)
|
|
- r = -1;
|
|
+ if (cpu < 0 || cpuset_cpubind(cpu) < 0)
|
|
+ break;
|
|
|
|
cpuset_free_placement(plc2);
|
|
plc2 = cpuset_get_placement(0);
|
|
+ if (!plc2)
|
|
+ break;
|
|
+ r = 0;
|
|
} while (!cpuset_equal_placement(plc1, plc2));
|
|
|
|
cpuset_free_placement(plc1);
|
|
@@ -3644,13 +3650,20 @@ int cpuset_size()
|
|
return -1;
|
|
|
|
do {
|
|
+ r = -1;
|
|
cpuset_free_placement(plc1);
|
|
plc1 = cpuset_get_placement(0);
|
|
+ if (!plc1)
|
|
+ break;
|
|
|
|
r = cpuset_cpus_weight(0);
|
|
|
|
cpuset_free_placement(plc2);
|
|
plc2 = cpuset_get_placement(0);
|
|
+ if (!plc2) {
|
|
+ r = -1;
|
|
+ break;
|
|
+ }
|
|
} while (!cpuset_equal_placement(plc1, plc2));
|
|
|
|
cpuset_free_placement(plc1);
|
|
@@ -3668,13 +3681,22 @@ int cpuset_where()
|
|
return -1;
|
|
|
|
do {
|
|
+ r = -1;
|
|
cpuset_free_placement(plc1);
|
|
plc1 = cpuset_get_placement(0);
|
|
+ if (!plc1)
|
|
+ break;
|
|
|
|
r = cpuset_p_sys_to_rel_cpu(0, cpuset_latestcpu(0));
|
|
+ if (r < 0)
|
|
+ break;
|
|
|
|
cpuset_free_placement(plc2);
|
|
plc2 = cpuset_get_placement(0);
|
|
+ if (!plc2) {
|
|
+ r = -1;
|
|
+ break;
|
|
+ }
|
|
} while (!cpuset_equal_placement(plc1, plc2));
|
|
|
|
cpuset_free_placement(plc1);
|