Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2382433lqp; Sun, 24 Mar 2024 16:59:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVoGzdMzBirM8Wm/OjtjXVMo9W93nTY+aK1QJRwNF3VbnvmID2Soc9SCDbPer654LgebyGJhsvFCqBQBb/dAVwDuP1p2o6wrMbZ5lzuvw== X-Google-Smtp-Source: AGHT+IG6vVpciDNo1oBvEh7eYd+pZ+tgrwcVFzRdTQdXjiM4Ye/nMgaxwlwl1ABBqa0pbJ/A6lS6 X-Received: by 2002:ad4:5d46:0:b0:691:3549:340a with SMTP id jk6-20020ad45d46000000b006913549340amr8781545qvb.42.1711324763530; Sun, 24 Mar 2024 16:59:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711324763; cv=pass; d=google.com; s=arc-20160816; b=u9Z/64+0e71M5pSGP9iq3lfjG3rc/kHqC7EgQaIHst16CffJ6ezwux/TuZz8fut4YN PWiUXIsizrOe3XdSszDHm5TuXtItg2D2In3gHJ0zYTAdW5o6nSPKDatAwcxEsALSXWiC MkVmXbAiQz1G0JQ9JYUdnTO1lrMS6sKlDUNG/0brGc8Q5fBjfONRw57gngFcupRTWIYP CJdaHVHMW88U0AT2wd5benH6p4DuRWZIuDKj+OAtP3Kb0Th3rqy4yPzvwM34joAgNDh0 dMlsOYA4FVf3lXmMB1UKOAnczjZDUs5IWO+BRHaGLpI7ygZHf81njwQySJ0CX9r+mZRG ZhAg== ARC-Message-Signature: i=2; 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/pL8RSf7+mgzp41ATSJPFjtFaEr2lgxH+wn0DAoBh9c=; fh=i4sDjfem60wtH+YpE6xF3G/imIo2Hgc0X9EXgxhGfzY=; b=SdhPDDagY0TthvFoi1hBGSKuFcsg98liFAjxvMoK6wc+D8KPZwDmyrRE+4tkvvnFQ2 YZmGwaAYUk6RBc8xQ9F27305HiXOfH7zbNLBgg55+u2+mRfmcS2XBcg8aPoy1Hs6WrL2 ODDq8o9Ic2ZsbsY6U33MoYZbGfEyZI+lfzhrX/kjPSYbExNCLuAzK9Z7ZQNpcYLIG+lj Bi554YUNV9ZuDCCV1nUE73g9ZZ4V4NKLc/rAyRVRWUNOQsjad4yXbMtDHdzDddkQ71We tgiulagwB+Bcwjw2kfxSlGA3XNjfhzXQIALPQQLe2aVVkT5qJ3sp/Ctck7v8zLIaeAn+ QSxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pkc3nfX5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jp15-20020ad45f8f000000b006915ae114edsi6699513qvb.337.2024.03.24.16.59.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:59:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pkc3nfX5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4108A1C2318A for ; Sun, 24 Mar 2024 23:59:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0B845FB93; Sun, 24 Mar 2024 22:41:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pkc3nfX5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B0C1118BC40; Sun, 24 Mar 2024 22:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320077; cv=none; b=S7/nTFprW3Ed8dEF4LueRa5UDSrqR/XAgFPz5PlgfuJa0iFgKpkhHQeQ0DF1H5D7q9vvCOeg9pl4VAuAr2yqyloFozdLijVe0G1Xx1Plx5dwMAVO/wSiQMI1WwWmjVTfdJFwoS0iLHUE4XZQVRPhSPdGxg7U4fLlBAtOeKPCzRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320077; c=relaxed/simple; bh=0V0modpgI+8Pr8qgQ7JsqrWWI9vJdi3MzunN4UFnEr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XSYkZYWdOVejs/M22+Ovg1tnnYlpH0k2Qe4XcTTUxa4gOrdgUGlY1+foW6YS3Vgs5cOwfGKxOtjwJxDTrKeYFkrcuycQgaZPpN9XYddRuvsV+eF20L9X+/ka+X29e2/C2SKTY9FPOcOgeB+mbCTHgdBouG3z0/kJdAFCVYH8Fm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pkc3nfX5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDE0AC43399; Sun, 24 Mar 2024 22:41:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320077; bh=0V0modpgI+8Pr8qgQ7JsqrWWI9vJdi3MzunN4UFnEr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pkc3nfX52eVBzXCdWptRSa2KHw2DBZCG6gd5cZmiEYgEpXnmuNMsXfiIxk5Y/msX6 p5j/lndEaLjPASIZVC7j9iVSVYOPu4/DENabqbrR3zsaq7yKzwagKejJ43SiQgeVb1 tEzIUi2yPF7S94r8fx3Fm8zCF1zxsFP6jiX7/FarOoBaD3PQDePCicrNxl4G0TVDL0 mxB3FauVNSD5vqBDIDTzCVRIJ5unFSnQvnmsIaXG0dpEZZX67so4t9/K42gu4jSlwM N/84h/SxB8tAz4ETOakvx/5DrkbLTUUkzxzcAvQzAXaWQsjBUtjz1/OkmIAAKTK/Ob O0XFVeIAHIDUQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Claudiu Beznea , Dan Carpenter , Geert Uytterhoeven , Sasha Levin Subject: [PATCH 6.8 386/715] pinctrl: renesas: rzg2l: Fix locking in rzg2l_dt_subnode_to_map() Date: Sun, 24 Mar 2024 18:29:25 -0400 Message-ID: <20240324223455.1342824-387-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Claudiu Beznea [ Upstream commit bd433c25ca81b2ac6dca7ea288a8474eea4fb8a0 ] Commit d3aaa7203a17 ("pinctrl: renesas: rzg2l: Add pin configuration support for pinmux groups") introduced the possibility to parse pin configuration for pinmux groups. It did that by calling rzg2l_map_add_config() at the end of rzg2l_dt_subnode_to_map() and jumping to the remove_group label in case rzg2l_map_add_config() failed. But if that happens, the mutex will already be unlocked, thus this it will lead to double mutex unlock operation. To fix this move the rzg2l_map_add_config() call just after all the name argument is ready and before the mutex is locked. There is no harm in doing this, as this only parses the data from device tree that will be further processed by pinctrl core code. Fixes: d3aaa7203a17 ("pinctrl: renesas: rzg2l: Add pin configuration support for pinmux groups") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/all/f8c3a3a0-7c48-4e40-8af0-ed4e9d9b049f@moroto.mountain Signed-off-by: Claudiu Beznea Reviewed-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/20240115153453.99226-1-claudiu.beznea.uj@bp.renesas.com Signed-off-by: Geert Uytterhoeven Signed-off-by: Sasha Levin --- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c index 80fb5011c7bbc..01ef6921cb35c 100644 --- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c +++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c @@ -447,6 +447,16 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev *pctldev, name = np->name; } + if (num_configs) { + ret = rzg2l_map_add_config(&maps[idx], name, + PIN_MAP_TYPE_CONFIGS_GROUP, + configs, num_configs); + if (ret < 0) + goto done; + + idx++; + } + mutex_lock(&pctrl->mutex); /* Register a single pin group listing all the pins we read from DT */ @@ -474,16 +484,6 @@ static int rzg2l_dt_subnode_to_map(struct pinctrl_dev *pctldev, maps[idx].data.mux.function = name; idx++; - if (num_configs) { - ret = rzg2l_map_add_config(&maps[idx], name, - PIN_MAP_TYPE_CONFIGS_GROUP, - configs, num_configs); - if (ret < 0) - goto remove_group; - - idx++; - } - dev_dbg(pctrl->dev, "Parsed %pOF with %d pins\n", np, num_pinmux); ret = 0; goto done; -- 2.43.0