From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72845379996 for ; Mon, 23 Feb 2026 22:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771884097; cv=none; b=ad7GCZ8/g7zqx3/+oY+kHo/gz1Evaf3hOe+36IgDU+DjQNXUSOqHfXJqf+oLGYAcvyGkg0Om5fCAJztNayLqO766ovqkaWv6ky3fR7nnPS89MyY9fQyWKGn8OyICscmrwr0Ui5K5RwpDB8RIq1ajRKOc8ZdAngtBJcS+Nzg1tK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771884097; c=relaxed/simple; bh=0tBP5BscOH3N3vwVP0uhe79lDd1tLni+eXo9p6Vj0+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JgoSGvCVpfgJykQST5TFlViI0qco0/fc6gk/9Bsk4k65XdhFJ1q0D0HX7v9lmpAMw+UoMcbMVw1Qx0J1Wm5ddyU5ciSUCIYFTPdh2M5nSBdV4gCexfjs6lD73P5kYo4Rx1H5200JOuqqLoTtrgBbhx/ai9XACUsiSghb3DDE7es= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iKsJcJCO; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iKsJcJCO" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1771884094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Py2P1r/CaueFX7wsjQNF4qDKdF68aIQqofiLeicyHf4=; b=iKsJcJCOc4zp/KkntDoMTl4EMwPjvvrhs1gh61/YG2me4p2/pq5AsWOScgiiJ5Vq5MaYw0 IlQfgq1ow5lHtTY+Slk/TcCStp+E/oFSTHt5/XAsYO38YfQ9LhZU6kDNtCUXqNGtzUlDGu CliWsPzFYPackVc4TNZlb3Qkpv101tY= From: Bart Van Assche To: Peter Zijlstra Cc: Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , linux-kernel@vger.kernel.org, Marco Elver , Christoph Hellwig , Steven Rostedt , Nick Desaulniers , Nathan Chancellor , Kees Cook , Jann Horn , Bart Van Assche , Sumit Semwal , =?UTF-8?q?Christian=20K=C3=B6nig?= , linux-media@vger.kernel.org Subject: [PATCH 06/62] dma-buf: Handle all dma_resv_lock() errors Date: Mon, 23 Feb 2026 14:00:06 -0800 Message-ID: <20260223220102.2158611-7-bart.vanassche@linux.dev> In-Reply-To: <20260223220102.2158611-1-bart.vanassche@linux.dev> References: <20260223220102.2158611-1-bart.vanassche@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Bart Van Assche Instead of assuming that dma_resv_lock() only returns 0 or -EDEADLK, handle all possible dma_resv_lock() return values. This patch prepares for enabling compile-time thread-safety analysis. This will cause the compiler to check whether all dma_resv_lock() return values are handled. Cc: Sumit Semwal Cc: Christian König Cc: linux-media@vger.kernel.org Signed-off-by: Bart Van Assche --- drivers/dma-buf/dma-resv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c index bea3e9858aca..b4710f730e9b 100644 --- a/drivers/dma-buf/dma-resv.c +++ b/drivers/dma-buf/dma-resv.c @@ -792,6 +792,8 @@ static int __init dma_resv_lockdep(void) ret = dma_resv_lock(&obj, &ctx); if (ret == -EDEADLK) dma_resv_lock_slow(&obj, &ctx); + else if (ret) + goto fini; fs_reclaim_acquire(GFP_KERNEL); /* for unmap_mapping_range on trylocked buffer objects in shrinkers */ i_mmap_lock_write(&mapping); @@ -805,12 +807,14 @@ static int __init dma_resv_lockdep(void) #endif fs_reclaim_release(GFP_KERNEL); ww_mutex_unlock(&obj.lock); + +fini: ww_acquire_fini(&ctx); mmap_read_unlock(mm); mmput(mm); - return 0; + return ret; } subsys_initcall(dma_resv_lockdep); #endif