From patchwork Thu Jan 4 05:40:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuewen Yan X-Patchwork-Id: 184910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5430282dyb; Wed, 3 Jan 2024 21:41:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY5uy+ZSStNpl4vNYcchFA7zekw20WeiqlMiXy5+S+gdjGiOytLjuYz3Anx3/bxWJT5OK3 X-Received: by 2002:a05:6359:6316:b0:170:5398:81e5 with SMTP id sf22-20020a056359631600b00170539881e5mr28120rwb.39.1704346903005; Wed, 03 Jan 2024 21:41:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704346902; cv=none; d=google.com; s=arc-20160816; b=fFNK4CKxg1x3igZNOdJky0EgWXV3ww3jGmRfqqeNA4m1O2PBZmvQPsefjLn/S9Wlf8 c6T7D38fTNdlOfwhtuglLtp7yMAepV43tsjWMF10hgA1gLLESzJD+rmgYEAicHqLlcX8 ir7KRMIhEjwG4EMe6VW5U8s+3mOicbBG5PwnziqKReNDv6+Xg6pEvg5Xn5RVT4U0Jj14 fkXNCspsY2sTWi4Yfqr2KZXibiCeuYwmvWQPF1gg/rv9zz143r6EpTLuIxyWbhX0Zald RWCom34JmBYXiUxAQavc3hFqTETBt0NdKCTlbrk6GBl+/veVBVr6C1oi99jGmZxx7Xdl s5SA== ARC-Message-Signature: i=1; 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; bh=EsnJy+leTwKbzpG/0sU2DwnSB8aB+UajX9OfOZ++ZGA=; fh=fCbZmewdeCoNvgouhvn6BTfl32w0KLbPSiVoJrFPDA8=; b=FYcRzytLaOaZvCM1z82rP5FpQMVg5C6QaDEpAwsAGRq2MJXl2K2hK7XUygyWAhzOu6 MLRe2TUj90YVCG2f2/synlq7pSPu304HI9QkHIGpurDnWlU+/LcJ3Mm4DWnNRe0xLBAz LfAGidGeAkchNvwsXyyJZT5fmJ3PvDCLlieixkghcSRFC+RSLgVZef0k4GIIEuFB6bNO 2NEPV2mLaE9O1fBOzLuSDDSDN3CFASADyOYYXWws+CceFE8nnf1NQfcSmrKClqa2yIAX WkeR2+sqMjGc7/BGTIwmRgEUHCdjm2zusupE1lFUj4B9AR6h3q8fzNi/1IJ1RE2t8FrO IANA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16263-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16263-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id l4-20020a656804000000b005ce19c68671si17557489pgt.497.2024.01.03.21.41.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 21:41:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16263-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16263-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16263-ouuuleilei=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id ACD452882C5 for ; Thu, 4 Jan 2024 05:41:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91F081CA98; Thu, 4 Jan 2024 05:41:30 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) (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 8D38F18EBF for ; Thu, 4 Jan 2024 05:41:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4045eZCU057778; Thu, 4 Jan 2024 13:40:35 +0800 (+08) (envelope-from Xuewen.Yan@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4T5Fct75KXz2QcMNy; Thu, 4 Jan 2024 13:33:50 +0800 (CST) Received: from BJ10918NBW01.spreadtrum.com (10.0.73.73) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 4 Jan 2024 13:40:33 +0800 From: Xuewen Yan To: , , CC: , , , , Subject: [PATCH] lock/lockdep: Add missing graph_unlock in validate_chain Date: Thu, 4 Jan 2024 13:40:30 +0800 Message-ID: <20240104054030.14733-1-xuewen.yan@unisoc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 4045eZCU057778 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787137258149564842 X-GMAIL-MSGID: 1787137258149564842 The lookup_chain_cache_add will get graph_lock, but the validate_chain do not unlock before return 0. So add graph_unlock before return 0. Signed-off-by: Xuewen Yan Signed-off-by: Zhiguo Niu --- kernel/locking/lockdep.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 151bd3de5936..24995e1ebc62 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3855,8 +3855,11 @@ static int validate_chain(struct task_struct *curr, */ int ret = check_deadlock(curr, hlock); - if (!ret) + if (!ret) { + graph_unlock(); return 0; + } + /* * Add dependency only if this lock is not the head * of the chain, and if the new lock introduces no more @@ -3865,9 +3868,9 @@ static int validate_chain(struct task_struct *curr, * serializes nesting locks), see the comments for * check_deadlock(). */ - if (!chain_head && ret != 2) { - if (!check_prevs_add(curr, hlock)) - return 0; + if (!chain_head && ret != 2 && !check_prevs_add(curr, hlock)) { + graph_unlock(); + return 0; } graph_unlock();