Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3693787pxb; Mon, 24 Jan 2022 15:33:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxLrd1jfWTvv/fHc+zu7mWYSoqnjxVhCbu2Q0OGtOySfxWinZFe0oFCSSvPTyYzJHHABAvg X-Received: by 2002:a63:b24b:: with SMTP id t11mr13338207pgo.444.1643067206770; Mon, 24 Jan 2022 15:33:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067206; cv=none; d=google.com; s=arc-20160816; b=Fec1PV9FanvRVBCV26zgayTlax78iFKs+fBDvo/4b/h5fs162ottMfCT9DpjF8SfLL /6MdALMMlQbTlkgjDf0YY7jmzUAqaIwP3iomVbMi/9Obsp4Fhl4CkQ/hX7EIrp13NZ7c uRILgalSkAHVgpgVqFqqo3xQTUw/1fGZo1SimuPdEOvKv5p6mBvrvFUD0mI+EWpyWmBB pmzFRwNbpNg8u+8xXlXZsbEC/ddXTUdUFraHZE6Zmwr9D6Cwe8oGrZvknhyw7P7RFTZE BqlBkrzM+HoT2EZzhYBrg0y4NzG4eLrfh8Z1ggxeL0/g1z694bGkPSeBGlIO3pl9PkOa W0Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vH+u7KMVl6FPfYhEqZTLPOmf99p6QwHQxmYKD5Uql+E=; b=FkspbmMUM1dcPvxVQUAXz7AMj9KqueptqU9CxC/ax5YtWXeI6uWjjRddss/SRBAD14 Ec7HsfA2nTpQNuzSAyM6+sxuEmUBSQXjPuiXWJJwcNyWS7pLDeYkorh8LszTv7cLawvn kpjEbmfFLW1a2iS9BndFs9fUcdPdyR/oTI8EUpPzyDDM+CMQwg8V9/DxuynRUkhombnw wW3cFo0aNzirPN+vMxzovbO6/mNjN4BEeRA+JninQiaeon6OKXObWaxdreypPDX3bWYV pNsvDMrsEMqvA19UwVNEFGrxhRPCiKjnISFsA/ggIdn8ynzumWpFt0/txyNduH1MOw4F CL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IrqhCDvN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n68si13851979pfd.246.2022.01.24.15.33.13; Mon, 24 Jan 2022 15:33:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IrqhCDvN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1850057AbiAXX1V (ORCPT + 99 others); Mon, 24 Jan 2022 18:27:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1588120AbiAXWbl (ORCPT ); Mon, 24 Jan 2022 17:31:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE4D0C02B86A; Mon, 24 Jan 2022 12:56:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 95EE3B81057; Mon, 24 Jan 2022 20:56:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F31AC340E5; Mon, 24 Jan 2022 20:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057770; bh=N7iqN2dtcEyo4qkf5F6uhGxw3W2pDTN7WGAfMlTzNYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrqhCDvN3D6GkybQ/t4A0pjuPiwZNT4EQoSLlWhpdVesneLqn/fGx+uKxvTrX+wak b4osQ9NHnty/dpTYVGsN32BXVcgjT7s+XzkBFGzyI6cpdEdbDpE/eUIwDpQ2gWm4Yn 7rbPu1Emv18NKdo3Hnoa+7vcKerJCyQ59CD4oHLI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Sumit Semwal , Gustavo Padovan , =?UTF-8?q?Christian=20K=C3=B6nig?= , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= Subject: [PATCH 5.16 0073/1039] dma_fence_array: Fix PENDING_ERROR leak in dma_fence_array_signaled() Date: Mon, 24 Jan 2022 19:31:02 +0100 Message-Id: <20220124184127.628739269@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Hellström commit 95d35838880fb040ccb9fe4a48816bd0c8b62df5 upstream. If a dma_fence_array is reported signaled by a call to dma_fence_is_signaled(), it may leak the PENDING_ERROR status. Fix this by clearing the PENDING_ERROR status if we return true in dma_fence_array_signaled(). v2: - Update Cc list, and add R-b. Fixes: 1f70b8b812f3 ("dma-fence: Propagate errors to dma-fence-array container") Cc: Chris Wilson Cc: Sumit Semwal Cc: Gustavo Padovan Cc: Christian König Cc: "Christian König" Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linaro-mm-sig@lists.linaro.org Cc: # v5.4+ Signed-off-by: Thomas Hellström Reviewed-by: Christian König Link: https://patchwork.freedesktop.org/patch/msgid/20211129152727.448908-1-thomas.hellstrom@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/dma-buf/dma-fence-array.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/dma-buf/dma-fence-array.c +++ b/drivers/dma-buf/dma-fence-array.c @@ -104,7 +104,11 @@ static bool dma_fence_array_signaled(str { struct dma_fence_array *array = to_dma_fence_array(fence); - return atomic_read(&array->num_pending) <= 0; + if (atomic_read(&array->num_pending) > 0) + return false; + + dma_fence_array_clear_pending_error(array); + return true; } static void dma_fence_array_release(struct dma_fence *fence)