Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp298763pxf; Thu, 25 Mar 2021 04:31:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyg0mw3pUENvowiIUm7ox4jjHuF6PS1nWvG2phYDqe1HDuYo2HGQT2Q4Qa0Cd2Su5NVPAZL X-Received: by 2002:aa7:cdcf:: with SMTP id h15mr8470840edw.28.1616671891480; Thu, 25 Mar 2021 04:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616671891; cv=none; d=google.com; s=arc-20160816; b=tsbvVcv8VJFlGgKWhlULW8AdERgf+ryNcjYUjobl1tEMSndN+vN/i0zuiDMroHURLF /UKb0K/xUdbgWhydFRsFcaWRIvKMJIEDanlQLmz1v59FMfqGbGKFqZ40UQIPCU7Mb5wG ttdV2R3l95RTl+UD95A+AEdkx4Wus6s3Ex6431dSDvHeihKL5pPARCFUbAO9Vismm609 WnuYd9Tj/Zc+FadO4kvXcUAhp2WmL5dLieLSOrDzNS4lmtbsQnoYN2SIJfjcHu20DTfH CMvEAeA68/AWZODtvhJA+AVENoGtnFdIbALjbAPPa9jLOwzRj54iiFWlibfFoOOQSW01 kYPw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WdarMdN/RZnEooNjCB6WSPuRMJVaHkQhk/ZdeSLemZw=; b=M5GWm5B8HDYXPCgzvwNCdN+lqEWSGTYQ3/5j8ejO6NrLqEtT1fMaTjcVw2+yyyqNm4 wuSxN9JXEVA7lzPTOKgFXPgN6Sgw0qY87j+WUGc65zNqfgpU5KcSAKpQEaPwphO1z5i1 JB3iwoKJBWVO1XJ8vi8oWC3AHg/mrZnDq5aW29Pr99vGeQiCjWJjtvbOStf5WOukpVRR AEmIEgkGa95BEpVQ5SWI+KOA1m/RiGGOpQ4CXfvhbuh9d2ycQdjpHjs7dQ/krrBZYwW6 VJRxZodwjh2vvQrIKSQFXk9iIEdrKlM2+c7a7nHscjI6/qZAGF+7wAgafdslLwE1fj8K kyAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VNZb+F7K; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn25si4087055ejb.22.2021.03.25.04.31.08; Thu, 25 Mar 2021 04:31:31 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=VNZb+F7K; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231293AbhCYL2X (ORCPT + 99 others); Thu, 25 Mar 2021 07:28:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:34144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbhCYLZp (ORCPT ); Thu, 25 Mar 2021 07:25:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8673F61A31; Thu, 25 Mar 2021 11:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616671545; bh=S5j3nG5j6iipdN+6gyLF8VpxH2vLYLDsPzgnhRd8Xg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNZb+F7K5yG1ifxOAw5EJS2NDMNBEYsqNt8tDDHErdXPQSnFDeLNvIbB5qVL8lNBR 4tNMswLVwzmKU12moaTw97pMqmAA2f4spBwE1zY48Loa+GbGJcfAAaQeiuoEOWyOnf vAIStE0dKg1RiY5Xgtthg0VZmcsurVgSTdp7drAwqoJGv/xSVgYUPQX6Y/XUuEy9so NqhOyZrmnZlV/EPyZfoP4/0Ynaofk4zY9Di9nhJ/TJtBg7qQE/aaEpjC+PB975/EYi fa9NAsTV90Np3ygPDZwfqNvA7L2FbONVTmDU6pYVvkq2UtuXUoFemylzDiHCer6BWI oP2oMTPDRWAJw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Waiman Long , Ingo Molnar , Sasha Levin Subject: [PATCH AUTOSEL 5.11 35/44] locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini() Date: Thu, 25 Mar 2021 07:24:50 -0400 Message-Id: <20210325112459.1926846-35-sashal@kernel.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210325112459.1926846-1-sashal@kernel.org> References: <20210325112459.1926846-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Waiman Long [ Upstream commit bee645788e07eea63055d261d2884ea45c2ba857 ] In ww_acquire_init(), mutex_acquire() is gated by CONFIG_DEBUG_LOCK_ALLOC. The dep_map in the ww_acquire_ctx structure is also gated by the same config. However mutex_release() in ww_acquire_fini() is gated by CONFIG_DEBUG_MUTEXES. It is possible to set CONFIG_DEBUG_MUTEXES without setting CONFIG_DEBUG_LOCK_ALLOC though it is an unlikely configuration. That may cause a compilation error as dep_map isn't defined in this case. Fix this potential problem by enclosing mutex_release() inside CONFIG_DEBUG_LOCK_ALLOC. Signed-off-by: Waiman Long Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20210316153119.13802-3-longman@redhat.com Signed-off-by: Sasha Levin --- include/linux/ww_mutex.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/ww_mutex.h b/include/linux/ww_mutex.h index 850424e5d030..6ecf2a0220db 100644 --- a/include/linux/ww_mutex.h +++ b/include/linux/ww_mutex.h @@ -173,9 +173,10 @@ static inline void ww_acquire_done(struct ww_acquire_ctx *ctx) */ static inline void ww_acquire_fini(struct ww_acquire_ctx *ctx) { -#ifdef CONFIG_DEBUG_MUTEXES +#ifdef CONFIG_DEBUG_LOCK_ALLOC mutex_release(&ctx->dep_map, _THIS_IP_); - +#endif +#ifdef CONFIG_DEBUG_MUTEXES DEBUG_LOCKS_WARN_ON(ctx->acquired); if (!IS_ENABLED(CONFIG_PROVE_LOCKING)) /* -- 2.30.1