From patchwork Mon Mar 31 09:45:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 14033388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F06DFC3600B for ; Mon, 31 Mar 2025 09:45:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6743C10E3B4; Mon, 31 Mar 2025 09:45:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pSRENAaH"; dkim-atps=neutral Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 851DB10E3B4 for ; Mon, 31 Mar 2025 09:45:15 +0000 (UTC) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4394a0c65fcso40579495e9.1 for ; Mon, 31 Mar 2025 02:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1743414314; x=1744019114; darn=lists.freedesktop.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=aKS0Fboa1dtHIDG4S6gLCYTAz2lAP8mKMrYFIOMeSw4=; b=pSRENAaHj8LWOSytswu+gcqJHnC63LcWchjJWGLHBZyJNTgOk9QEY0csQGZVtEG3an LumP9cQvSbKY33+WFrDGua+hZudEK1sXOlAXbcw76rUJi9lzG9Di1QoaU7DrKpOWYLjD NNBJYcDD/m+aIZIMmQA9rzz2Ieiyt6ivNGaHd/3RZsE3VCnoGAShvAXMaXiklcpB9pRO LqSIpmO2A49OMSb0SVShTRIMwyVS7NsJtERLgGvneTH72gHjVsOONOCTDqE8/Ubeq1tG IDVhnfGjqr4EXOIbzxYBuni9rLl0GeXRx0UjzgXgq1GPVSpdTO3BcDr78WG1qWR29t4z wbEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743414314; x=1744019114; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aKS0Fboa1dtHIDG4S6gLCYTAz2lAP8mKMrYFIOMeSw4=; b=ofv7QszLNQtPYOCRCNn/pz/EhhH26kmbGI4mD1bXT8OJWjSdaunkoni3ikSG6ciBtW GAvgZJjHDXmuZRd4is/dC1FD+VaNpMG45RBK6PO/+uVvspHU6pVXRXucY71pdIkW5cUv NYTISmPCRNs4aEA6cp15IjXrVDxVjtxWT8fqe1SVqPqFQElDplHt82zBMpKvQlugrz84 qw7Rppv7Ipe50hBI9l4Vl+MUtMGGjvbxkm4k8mk67rFcND0D3TU6ZveoAQmGLJWYp3AV qqlEICSabr5psWjIL5daZlSeioab8UWmP1BbHG5a7TwOzSrnuVXPsiKRKvp/WZgUOaGf kksg== X-Forwarded-Encrypted: i=1; AJvYcCXi0w3rZDKnbCBrRJwFLtwwlSzrkKPekkChqM1OxXHwnMvyx4cMm4SDWcUwVHMmOHijbHURcuM3dZ4=@lists.freedesktop.org X-Gm-Message-State: AOJu0YwPTCCIU9JFHl5syGkD4c1kZ65fbR7ikFJ7TYdXgiQjP4tJFGHe ioHAe3v7BjoNaDKaW85zK1DWbcdqf9dHSO/FowxQfKSA1/XM3kLDiQyXtlUx+xH36tPfCu4lhvo Vn78= X-Gm-Gg: ASbGnctfrmoiRbjBAIbWKmp1RWpr9vncPeG2TJ1feFf61uOVgXbf2KCCjRLaT1ifHYT lTRKMDoz6UuLbmtpKemTMlZaf3VSLcg3sgDzrdUmDtA1fEDmB6xcCR9JWVwEtPKVFQH1KvEvh4w b/2IeNjKz16xZmXbp+aAe1mPrl9I9qY2I4v8hSUz+UmwKfcmqNEYLyIaY8WXm4QQCQP4dLgBmjW z969ORc1Gq/a8PjoiES6DhIPP6cbfC0dGcekwAnn5F7n4MWFIGEu1wWAypPk9CORf9jzFR1EwgS eVeFrUTcS4FBW+/FJyDS9MfNhHagpQSyBoYJUN6+wyLJIgOevA== X-Google-Smtp-Source: AGHT+IFVzFpYmKBAGEXWi3zw7wUU5N+0+BO4pZCgxv4I35ZkC0wJP7yiqMMStfAjpc9DsFCTgkEtog== X-Received: by 2002:a05:600c:83c4:b0:43c:ec28:d31b with SMTP id 5b1f17b1804b1-43db62283d1mr102074565e9.10.1743414313954; Mon, 31 Mar 2025 02:45:13 -0700 (PDT) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-43d8fbc10e1sm115778485e9.12.2025.03.31.02.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Mar 2025 02:45:13 -0700 (PDT) Date: Mon, 31 Mar 2025 12:45:11 +0300 From: Dan Carpenter To: Rob Clark Cc: Sumit Semwal , Gustavo Padovan , Christian =?iso-8859-1?q?K=F6nig?= , Dmitry Baryshkov , Pekka Paalanen , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] dma-buf/sw_sync: Decrement refcount on error in sw_sync_ioctl_get_deadline() Message-ID: <5dbd6105-3acf-47ad-84d6-2920171916ac@stanley.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Call dma_fence_put(fence) before returning an error on this error path. Fixes: 70e67aaec2f4 ("dma-buf/sw_sync: Add fence deadline support") Signed-off-by: Dan Carpenter --- drivers/dma-buf/sw_sync.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c index f5905d67dedb..b7615c5c6cac 100644 --- a/drivers/dma-buf/sw_sync.c +++ b/drivers/dma-buf/sw_sync.c @@ -438,8 +438,10 @@ static int sw_sync_ioctl_get_deadline(struct sync_timeline *obj, unsigned long a return -EINVAL; pt = dma_fence_to_sync_pt(fence); - if (!pt) + if (!pt) { + dma_fence_put(fence); return -EINVAL; + } spin_lock_irqsave(fence->lock, flags); if (test_bit(SW_SYNC_HAS_DEADLINE_BIT, &fence->flags)) {