.. | .. |
---|
180 | 180 | if (in_shutdown++) |
---|
181 | 181 | return; |
---|
182 | 182 | |
---|
| 183 | + /* Free the cpu_set allocated using CPU_ALLOC in main function */ |
---|
| 184 | + CPU_FREE(cpu_set); |
---|
| 185 | + |
---|
183 | 186 | for (i = 0; i < num_cpus_to_pin; i++) |
---|
184 | 187 | if (cpu_threads[i]) { |
---|
185 | 188 | pthread_kill(cpu_threads[i], SIGUSR1); |
---|
.. | .. |
---|
551 | 554 | perror("sysconf(_SC_NPROCESSORS_ONLN)"); |
---|
552 | 555 | exit(1); |
---|
553 | 556 | } |
---|
| 557 | + |
---|
| 558 | + if (getuid() != 0) |
---|
| 559 | + ksft_exit_skip("Not running as root, but almost all tests " |
---|
| 560 | + "require root in order to modify\nsystem settings. " |
---|
| 561 | + "Exiting.\n"); |
---|
| 562 | + |
---|
554 | 563 | cpus_online = min(MAX_CPUS, sysconf(_SC_NPROCESSORS_ONLN)); |
---|
555 | 564 | cpu_set = CPU_ALLOC(cpus_online); |
---|
556 | 565 | if (cpu_set == NULL) { |
---|
.. | .. |
---|
589 | 598 | cpu_set)) { |
---|
590 | 599 | fprintf(stderr, "Any given CPU may " |
---|
591 | 600 | "only be given once.\n"); |
---|
592 | | - exit(1); |
---|
| 601 | + goto err_code; |
---|
593 | 602 | } else |
---|
594 | 603 | CPU_SET_S(cpus_to_pin[cpu], |
---|
595 | 604 | cpu_set_size, cpu_set); |
---|
.. | .. |
---|
607 | 616 | queue_path = malloc(strlen(option) + 2); |
---|
608 | 617 | if (!queue_path) { |
---|
609 | 618 | perror("malloc()"); |
---|
610 | | - exit(1); |
---|
| 619 | + goto err_code; |
---|
611 | 620 | } |
---|
612 | 621 | queue_path[0] = '/'; |
---|
613 | 622 | queue_path[1] = 0; |
---|
.. | .. |
---|
622 | 631 | fprintf(stderr, "Must pass at least one CPU to continuous " |
---|
623 | 632 | "mode.\n"); |
---|
624 | 633 | poptPrintUsage(popt_context, stderr, 0); |
---|
625 | | - exit(1); |
---|
| 634 | + goto err_code; |
---|
626 | 635 | } else if (!continuous_mode) { |
---|
627 | 636 | num_cpus_to_pin = 1; |
---|
628 | 637 | cpus_to_pin[0] = cpus_online - 1; |
---|
629 | 638 | } |
---|
630 | | - |
---|
631 | | - if (getuid() != 0) |
---|
632 | | - ksft_exit_skip("Not running as root, but almost all tests " |
---|
633 | | - "require root in order to modify\nsystem settings. " |
---|
634 | | - "Exiting.\n"); |
---|
635 | 639 | |
---|
636 | 640 | max_msgs = fopen(MAX_MSGS, "r+"); |
---|
637 | 641 | max_msgsize = fopen(MAX_MSGSIZE, "r+"); |
---|
.. | .. |
---|
740 | 744 | sleep(1); |
---|
741 | 745 | } |
---|
742 | 746 | shutdown(0, "", 0); |
---|
| 747 | + |
---|
| 748 | +err_code: |
---|
| 749 | + CPU_FREE(cpu_set); |
---|
| 750 | + exit(1); |
---|
| 751 | + |
---|
743 | 752 | } |
---|