[lvc-project] [PATCH 1/2] dma-mapping: benchmark: fix up kthread creation error handling

Barry Song 21cnbao at gmail.com
Fri May 3 04:36:30 MSK 2024


On Fri, May 3, 2024 at 4:29 AM Fedor Pchelkin <pchelkin at ispras.ru> wrote:
>
> If a kthread creation fails for some reason then uninitialized members of
> the tasks array will be accessed on the error path since it is allocated
> by kmalloc_array().
>
> Limit the bound in such case.
>
> Found by Linux Verification Center (linuxtesting.org).
>
> Fixes: 65789daa8087 ("dma-mapping: add benchmark support for streaming DMA APIs")
> Signed-off-by: Fedor Pchelkin <pchelkin at ispras.ru>
> ---

Reviewed-by: Barry Song <baohua at kernel.org>

>  kernel/dma/map_benchmark.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/kernel/dma/map_benchmark.c b/kernel/dma/map_benchmark.c
> index 02205ab53b7e..ea938bc6c7e3 100644
> --- a/kernel/dma/map_benchmark.c
> +++ b/kernel/dma/map_benchmark.c
> @@ -118,6 +118,7 @@ static int do_map_benchmark(struct map_benchmark_data *map)
>                 if (IS_ERR(tsk[i])) {
>                         pr_err("create dma_map thread failed\n");
>                         ret = PTR_ERR(tsk[i]);
> +                       threads = i;
>                         goto out;
>                 }
>
> --
> 2.45.0
>
>



More information about the lvc-project mailing list