Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3353450pxf; Mon, 5 Apr 2021 09:48:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgFuPNMZ8MvDYm/1qsMcd13+3NmgYkYSFrz2sdh5G16Xa84v1XMl0K8AxVhJuGHoHUqOcY X-Received: by 2002:aa7:dbd3:: with SMTP id v19mr32078590edt.314.1617641293484; Mon, 05 Apr 2021 09:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617641293; cv=none; d=google.com; s=arc-20160816; b=ZaAobRV9s/WwYoDwXON7n9ngoDd0Xpcq8LJHrqJvZrrlNsF7Ou6jV+vrynrD9VRjvq 5A+y8O7kXS2vazBYhTbmXDoglDKcgmwRxoZ0Y3kB/+lTvrhE40bqL/sZXME1u/JnH3sG ZBVaXx02xz5LDJ8qW9ojJv/ROyChEqNGAj6ScSIceqCMFsC3sWHIbUj4H+nlRbM6pfpE dgl+gZ+Wg5KwYQ8sQXRmryqzP06L1svxj1NsLto15aLmqA823wYgPoT0IgbuTXWLtsyO qUj19TAxRxJJUId7AwLOVuBJS/E3g1zxZOcloFymh3R7PqwsliOnH78uImurE8PMj0gk hF2w== 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=WdarMdN/RZnEooNjCB6WSPuRMJVaHkQhk/ZdeSLemZw=; b=fKPnQ5aXJ7R56ah+oeGLrAGSXEq82r87FfGJPbEfny6rQZfA/HYnL9REWFkauN/qW7 taxLBmwAhNR+PZBFZOS2ma011b3m5yyb8dYH77iBYwu9VGZqiJVqsAHAfLqlvIQq2n60 cg3AKFC9W18qZ53DdnmsM9FhRUoXFi8T9lgK3+InvpXHtnmUskvsUUIlWLD1+FZhXZxn yGj0GVoZZm+UYxwo1fx+yEuWAFtxNTud9otJcm8mdDOhy+wlxunUQO3yEvE4lR1MBqwO yYRh96/ecl4vbYtz0pzymHOjT8k47fJlWXG7rYtRuGZyK5Vtedzre+q5lPR5QI0k8pWI 5jhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vkRTsaKL; 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 ds10si9214592ejc.415.2021.04.05.09.47.49; Mon, 05 Apr 2021 09:48:13 -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=@linuxfoundation.org header.s=korg header.b=vkRTsaKL; 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 S239905AbhDEJSH (ORCPT + 99 others); Mon, 5 Apr 2021 05:18:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:34038 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239821AbhDEJOV (ORCPT ); Mon, 5 Apr 2021 05:14:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE95461002; Mon, 5 Apr 2021 09:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617614056; bh=S5j3nG5j6iipdN+6gyLF8VpxH2vLYLDsPzgnhRd8Xg0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vkRTsaKLhPUKWWgL+5hq+JvpauZku6sXKqJTHckLn99a6buyEhhSRf96mmb3DcIRB CHHII66ifTlHqaMl/LpDmjhLYrYqXU2ICenjTOFl3S630H3ZlC5t3hvA8U3HQGiE/n Tq9osjuC07gbSNl1/8NL6ZGJw8YQgKBLxGEjmuOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Waiman Long , Ingo Molnar , Sasha Levin Subject: [PATCH 5.11 032/152] locking/ww_mutex: Fix acquire/release imbalance in ww_acquire_init()/ww_acquire_fini() Date: Mon, 5 Apr 2021 10:53:01 +0200 Message-Id: <20210405085035.298202087@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085034.233917714@linuxfoundation.org> References: <20210405085034.233917714@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: 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