rt-tests: cyclicdeadline: fix segmentation fault on close
PATCH 1/1 rt-tests: cyclicdeadline: fix segmentation fault on close
The setcpu_buf is unconditionally freed at the end of the program. However, there are code paths in which it is not allocated:
$ sudo ./cyclicdeadline
Using all CPUS
/sys/kernel/debug/sched_features: Success
interval: 600:1000
Tested at 5us of 600us
deadline thread 2963
thread[2963] runtime=600us deadline=1000us
main thread 2962
fail 2 0
T: 0 ( 2963) I:1000 C: 1268 Min: 7 Act: 55 Avg: 56 Max: 256
[1] 2961 segmentation fault sudo ./cyclicdeadlineFix it by adding the NULL check.
Signed-off-by Kurt Kanzenbach <[email protected]>
--- src/sched_deadline/cyclicdeadline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/sched_deadline/cyclicdeadline.c +2 -1
@@ -1261,6 +1261,7 @@ int main (int argc, char **argv) } } -free (setcpu_buf); +if (setcpu_buf) +free (setcpu_buf);return 0 ; }
Signature · 1 line
2.11.0
Hi,
Quoted 15 lines · Kurt Kanzenbach
The
setcpu_bufis unconditionally freed at the end of the program. However, there are code paths in which it is not allocated:$ sudo ./cyclicdeadline Using all CPUS /sys/kernel/debug/sched_features: Success interval: 600:1000 Tested at 5us of 600us deadline thread 2963 thread[2963] runtime=600us deadline=1000us main thread 2962 fail 2 0 T: 0 ( 2963) I:1000 C: 1268 Min: 7 Act: 55 Avg: 56 Max: 256 [1] 2961 segmentation fault sudo ./cyclicdeadline
Quoted 1 line
Fix it by adding the NULL check.
free(3) is actually NULL safe. So, that's not the problem. We're debugging it.
Thanks,
Kurt