From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 295AE606A327 for ; Wed, 2 Dec 2026 09:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=am/AND/p; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hapVg0Zn DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=Q+Yz1AZHTkjwQx71lPw/mE4JBgzQ6xlKx3/o8pIdnhs=; b=am/AND/pM+WqhQ WwtEOG4pElahKU3wJejm7xNTkbVqp9/aThJFeJNt/BGxzgzadyudMfBEvZez/VUHxrplvMzj3v3Yk woAPWiTD1q7ROj3XfBx6ApitJ5r6fbk33K3BeQRbUQl4fQHPLxS860qVoZSYfa284KOjAYerkVc7e 5lXhUGlXkL7Mdahv1ayFls5QK1DhPm//RnalejG2SwWGUttX8LYFDNJuVCUIg193JhRP4+SQbUCrA TFfiY9FIL20lG3AgXceLyY/nEBaPNWO5C1Yta9Keym4UaDs2VwW38y14MiWxLNMOLpeNYnwvKto+3 hUH1A64lGt1G5C6lAnYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYggr-0000000AqEp-25mr; Wed, 02 Dec 2026 09:31:53 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYggq-0000000AqED-19u6 for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 09:31:52 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 0E03440886; Wed, 2 Dec 2026 09:31:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 538381F008A0; Wed, 2 Dec 2026 09:31:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796203911; bh=Q+Yz1AZHTkjwQx71lPw/mE4JBgzQ6xlKx3/o8pIdnhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hapVg0Zn11xgUic5mRy7P83hbSWn2v0WsFPGQodznf0x7vTzIe6VyGgTrZ3JHekIi 2Y6PBhETb30Bn6gzu4nrwz0T99E4YoTD7zd6Oi6BnAeO6sgWCvfHPbkEcbiHdHP1wd 5WZwwC0a1nQXeeaeF3yjomUvjjEnwUGqliKHgpvY1zXeuTjDKUbmwqOKjH+QgiifgR xwy7fhxNC4o0v2ZWN45AH9xD+XQ5JYa8Lh63PPdOnDbSfXEpZqbhu/hfZW/v909y2L y6QkKYNgvZZhuCSuoR5MttS55dmx69qF/Aa2BBQpSJZPfJyRrjS4AKI6wgNbKu+Lj/ VPZczVDT/jAEw== From: Lee Jones To: lee@kernel.org, Tony Lindgren , Haojian Zhuang , Linus Walleij , Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH 03/12] pinctrl: single: Protect group and function updates with pctldev->mutex Date: Wed, 2 Dec 2026 09:29:57 +0000 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 pcs_parse_one_pinctrl_entry() and pcs_parse_bits_in_pinctrl_entry() mutate pcs->pctl->pin_function_tree and pcs->pctl->pin_group_tree via pcs_add_function(), pinctrl_generic_add_group(), and their removal helpers while holding only the driver-private pcs->mutex. However, the pinctrl core debugfs readers and teardown paths traverse and modify those radix trees under pctldev->mutex, leaving concurrent readers and writers racing without a shared lock. Acquire pcs->pctl->mutex instead of pcs->mutex in both parsing functions so all generic group and function tree operations are serialised against the pinctrl core. Fixes: a4ab10860723 ("pinctrl: single: Fix group and function selector use") Closes: https://sashiko.dev/#/bug/linux-e32b7426-4575-4354-a2fe-409cde3480ce Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- drivers/pinctrl/pinctrl-single.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index e351cdf50669..618f8fc6ee6c 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -1059,7 +1059,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, } pgnames[0] = np->name; - mutex_lock(&pcs->mutex); + mutex_lock(&pcs->pctl->mutex); fsel = pcs_add_function(pcs, &function, np->name, vals, found, pgnames, 1); if (fsel < 0) { @@ -1102,7 +1102,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, devm_kfree(pcs->dev, function); devm_kfree(pcs->dev, pgnames); } - mutex_unlock(&pcs->mutex); + mutex_unlock(&pcs->pctl->mutex); return 0; @@ -1118,7 +1118,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, if (pinmux_generic_get_function(pcs->pctl, fsel)->data == function) pinmux_generic_remove_function(pcs->pctl, fsel); free_pins: - mutex_unlock(&pcs->mutex); + mutex_unlock(&pcs->pctl->mutex); devm_kfree(pcs->dev, pins); free_vals: @@ -1229,7 +1229,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, } pgnames[0] = np->name; - mutex_lock(&pcs->mutex); + mutex_lock(&pcs->pctl->mutex); fsel = pcs_add_function(pcs, &function, np->name, vals, found, pgnames, 1); if (fsel < 0) { @@ -1254,7 +1254,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, devm_kfree(pcs->dev, function); devm_kfree(pcs->dev, pgnames); } - mutex_unlock(&pcs->mutex); + mutex_unlock(&pcs->pctl->mutex); return 0; @@ -1263,7 +1263,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, if (pinmux_generic_get_function(pcs->pctl, fsel)->data == function) pinmux_generic_remove_function(pcs->pctl, fsel); free_pins: - mutex_unlock(&pcs->mutex); + mutex_unlock(&pcs->pctl->mutex); devm_kfree(pcs->dev, pins); free_vals: -- 2.56.1.911.g883d8bcb20-goog