mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] dma-buf: handle testing kthreads creation failure
@ 2024-05-22 18:13 Fedor Pchelkin
  2024-05-22 18:33 ` T.J. Mercier
  0 siblings, 1 reply; 3+ messages in thread
From: Fedor Pchelkin @ 2024-05-22 18:13 UTC (permalink / raw)
  To: Christian König, Sumit Semwal
  Cc: Fedor Pchelkin, Chris Wilson, Daniel Vetter, linux-media,
	dri-devel, linaro-mm-sig, linux-kernel, Alexey Khoroshilov,
	lvc-project, T.J. Mercier, stable

kthread creation may possibly fail inside race_signal_callback(). In
such a case stop the already started threads, put the already taken
references to them and return with error code.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 2989f6451084 ("dma-buf: Add selftests for dma-fence")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
v2: use kthread_stop_put() to actually put the last reference as
    T.J. Mercier noticed;
    link to v1: https://lore.kernel.org/lkml/20240522122326.696928-1-pchelkin@ispras.ru/

 drivers/dma-buf/st-dma-fence.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
index b7c6f7ea9e0c..6a1bfcd0cc21 100644
--- a/drivers/dma-buf/st-dma-fence.c
+++ b/drivers/dma-buf/st-dma-fence.c
@@ -540,6 +540,12 @@ static int race_signal_callback(void *arg)
 			t[i].before = pass;
 			t[i].task = kthread_run(thread_signal_callback, &t[i],
 						"dma-fence:%d", i);
+			if (IS_ERR(t[i].task)) {
+				ret = PTR_ERR(t[i].task);
+				while (--i >= 0)
+					kthread_stop_put(t[i].task);
+				return ret;
+			}
 			get_task_struct(t[i].task);
 		}
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-27 15:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22 18:13 [PATCH v2] dma-buf: handle testing kthreads creation failure Fedor Pchelkin
2024-05-22 18:33 ` T.J. Mercier
2024-05-27 15:01   ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®