dma-mapping: benchmark: fix up kthread-related error handling
authorFedor Pchelkin <pchelkin@ispras.ru>
Sat, 4 May 2024 11:47:01 +0000 (14:47 +0300)
committerChristoph Hellwig <hch@lst.de>
Thu, 23 May 2024 13:06:47 +0000 (15:06 +0200)
commitbb9025f4432f8c158322cf2c04c2b492f23eb511
tree0af448ed77cda24d7c3dbbe80e4c4b2d4d7e0831
parentc760b3725e52403dc1b28644fb09c47a83cacea6
dma-mapping: benchmark: fix up kthread-related error handling

kthread creation failure is invalidly handled inside do_map_benchmark().
The put_task_struct() calls on the error path are supposed to balance the
get_task_struct() calls which only happen after all the kthreads are
successfully created. Rollback using kthread_stop() for already created
kthreads in case of such failure.

In normal situation call kthread_stop_put() to gracefully stop kthreads
and put their task refcounts. This should be done for all started
kthreads.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 65789daa8087 ("dma-mapping: add benchmark support for streaming DMA APIs")
Suggested-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
kernel/dma/map_benchmark.c