[LTP] [PATCH v1 2/2] Prevent segmentation fault when negative task count specified

Andrea Cervesato andrea.cervesato@suse.com
Wed Sep 13 10:54:42 CEST 2023


Hi!

patch is simple enough to be applied, but this test really needs to be 
refactored, as it's almost untouched for 15 years now and we moved to 
new API long time ago.

Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com>

On 9/12/23 16:43, Marius Kittler wrote:
> Signed-off-by: Marius Kittler <mkittler@suse.de>
> ---
>   testcases/realtime/func/rt-migrate/rt-migrate.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/testcases/realtime/func/rt-migrate/rt-migrate.c b/testcases/realtime/func/rt-migrate/rt-migrate.c
> index 2554f63e2..252e77e6a 100644
> --- a/testcases/realtime/func/rt-migrate/rt-migrate.c
> +++ b/testcases/realtime/func/rt-migrate/rt-migrate.c
> @@ -419,6 +419,10 @@ int main(int argc, char **argv)
>   		numcpus = sysconf(_SC_NPROCESSORS_ONLN);
>   		nr_tasks = numcpus + 1;
>   	}
> +	if (nr_tasks < 0) {
> +		printf("The number of tasks must not be negative.\n");
> +		exit(EXIT_FAILURE);
> +	}
>   
>   	intervals = malloc(sizeof(stats_container_t) * nr_tasks);
>   	if (!intervals)

Andrea



More information about the ltp mailing list