Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp526740lqp; Wed, 22 May 2024 11:14:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUy1X+quB2plhB17Njk5aSmTXb+B+juSzCs+bS8Dijaohv+WCrxcDE/fEaC0SscNhyw5p+G7OiCFenjy4SDfmkCd6qzAWFvDNN1nY4UMQ== X-Google-Smtp-Source: AGHT+IFNo2ilCBhjfOTjLrP+ciMxKFnoufPFDMPdUis0dlfP75kzYOikkoWox+gsEFGizkgx8vfB X-Received: by 2002:a05:620a:13fc:b0:78e:f418:9737 with SMTP id af79cd13be357-794994c55a0mr247774485a.75.1716401668377; Wed, 22 May 2024 11:14:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716401668; cv=pass; d=google.com; s=arc-20160816; b=E3pcQeDeEaCzB2trazxmek82ZK+wyhA10DobkTUEketesC34h+FRDrLIptH6EI/y/f tIsTDcQO3+6210Q208r0e2U+inu9uTHorzOVRzHqmYqZXB4sN+GuPPKthYDJVEIXomUF Sbn2v6vdV2Sj/Ia5bp/zM1yLl+aGCbQRhima/aCoG4zbWoO/Yos1MtC9zu/hPZfZajqO 06LMfW63rxrykjAt3TecytPcyZVKq+60DDQaiPmUdaNWnqfd6fUHKmvkQwqxGZkVYtYf Jp8Ex/lSpPbgH/ME60sF+oUN4S7oApvQSEiXk9MU5gGY2Bn/28YQ31olxXG2QnuwdsOS IlIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature:dkim-filter; bh=Imz5WELE7gK/KIIyH94s3uVtNby+XXwDNZ6i3Up+9+0=; fh=pxZCwNK7huM+hLpD43KximQTs64lxo1g/v2FwABnUGc=; b=Ohf2a2IGG15KXpZBybE5ihyK8pjWR0TsBNoWzy18zkuAAmITyoTVkLorcsipXGVdcf rZFaT83WGYe+hlHTBTdANxPopD2YyFJKgPxAGJYonHIQQUKrzpyDhl/8fBFs1dBVK7BU Gj1Or3aEutgOS2ZfwhjO3/s1Bwv56j24vvTVa1YdLAUvpBWw3PG2cBZGI+PrkBgqgYou VPoO1e+pLx+jcl/UT5I6QbNN+PlJrhXAh8b8uGNIF/iUVplwi65TxohBHIB5e5bhTvq+ S2deHBn7bcE3Zl8+JB8pAj+eMTzhc4HAmxVyGlWYGwKTqDqEHcERxH5xBT6bZ3HjLxpZ 5zbw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=PwQLBlMz; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-186604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-79496308e92si457657485a.393.2024.05.22.11.14.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 11:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=PwQLBlMz; arc=pass (i=1 spf=pass spfdomain=ispras.ru dkim=pass dkdomain=ispras.ru dmarc=pass fromdomain=ispras.ru); spf=pass (google.com: domain of linux-kernel+bounces-186604-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186604-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 705EE1C2197F for ; Wed, 22 May 2024 18:14:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F344145B2E; Wed, 22 May 2024 18:14:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b="PwQLBlMz" Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EA1DA929; Wed, 22 May 2024 18:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.149.199.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716401658; cv=none; b=Hvyp4wCcHqBqeNqbMIqbdmyX22KTIScnN+ZAF0C9twf4rr7nCLOrt6DWgnpf5VL7pYK5/SGRGh3CQro/3aKiSmVIMBYvnocfbP6KG4LzpV+M7fBBXv9abdddGTDsk7J42L7DqpzTDDHEeuKu4HCehQ+EhYSq30aoKDqiswvLLrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716401658; c=relaxed/simple; bh=RvVkosRpeyj9j/AnzllgMBKI6qNAPpxdxuaRh0mQIMs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=snA4ZSSxHFcPwsRbWzsZ/UXc9IjDOc42rMPSo7lXy/M/SRJtfDZzbDayHF6OFMz7P2jCB6o5lnxT6pkFCEedjpUr+bf6H7CXoFdpnqcuNXGBOIzEUnbE5YKxAyE+e+7lT0gi4aCUQUolgRsO8VZb3I2glVLQ6XMhEtPl73mQDSM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru; spf=pass smtp.mailfrom=ispras.ru; dkim=pass (1024-bit key) header.d=ispras.ru header.i=@ispras.ru header.b=PwQLBlMz; arc=none smtp.client-ip=83.149.199.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ispras.ru Received: from fpc.intra.ispras.ru (unknown [10.10.165.15]) by mail.ispras.ru (Postfix) with ESMTPSA id 000114078505; Wed, 22 May 2024 18:14:10 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 000114078505 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1716401651; bh=Imz5WELE7gK/KIIyH94s3uVtNby+XXwDNZ6i3Up+9+0=; h=From:To:Cc:Subject:Date:From; b=PwQLBlMzotLiAng0Y2FrLpGSywzTylbdpLcYvuBEyzGO+5gnFrxHojCLr7ct+78VE BzFqINVtD47vCYbX4L0MHhj+7MhSAVZOhRfwwYypmZcnRco90zR3GmuWErKqL3kiit uPz6LmvIw3lrJaC0BWvQq+ZfGf9IAoLr+hDtmHC0= From: Fedor Pchelkin To: =?UTF-8?q?Christian=20K=C3=B6nig?= , Sumit Semwal Cc: Fedor Pchelkin , Chris Wilson , Daniel Vetter , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, "T.J. Mercier" , stable@vger.kernel.org Subject: [PATCH v2] dma-buf: handle testing kthreads creation failure Date: Wed, 22 May 2024 21:13:08 +0300 Message-Id: <20240522181308.841686-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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