Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3190984rdg; Tue, 17 Oct 2023 07:18:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAhwt2nrA+Q/1LVcY6cSunxr4q+KuqVOSAxPwSkreC7u4WUiDl45thRh0AOoq6Dq7ON57c X-Received: by 2002:a05:6359:2f8a:b0:14c:4f02:f3e with SMTP id rs10-20020a0563592f8a00b0014c4f020f3emr2543856rwb.21.1697552302303; Tue, 17 Oct 2023 07:18:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697552302; cv=none; d=google.com; s=arc-20160816; b=Vr/WVWFnDJxy5Tg2yEcdji/ms+bKa1hSrjkpm+ZfZiDbdFBgHMopL7Cpvc1uHPfWtr Rc2R/Kad4IjIIHjcNRUy059CH3d/TpZxrXG1WuOcExhXrqzoyMoKRn0mgrSCPpCtVX9t WRfXBex9Gx5QhKLgcvbAPIZjxKT+ciz0rf2mTQbd/O5HeUKD1Au98KG4kyBKJtUT0+lR cN5iJloI+KOeAvQEtck7uJRw+sh7AwPSgkHDEbnra3+pz3W1mk9vbYGWz76gy+inTUZ0 IvqqWaYY9yyDZKWWXOdgtV9RE7sIDqb2z2GcAlyJRoVpC/o/J+IESj8ZF6BJjgueAx8q qYiw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=nyFdG8PfEakZvdC76VIrPs8seNWmR3Mh/eAiXrMXj3I=; fh=eCZgxWiJIbDh8DQXDXBP+zA9mmVpYsM/Ihujt0tAon8=; b=Z+47qWUdcFXzESZVCRlzXowKY39iXzWniO6pmkDFqG3+eSJ9GekOz4AMLGSW8TKbcK +Fr5PXvlG7dKVjAm5oz2n/pxqvJTot/Mbn/PxYWAzhzi8wJrw52SUl32+rgorAJ5BOkE 2PxmJpAkvKglrT1z7GhHHRQsPXX/ijwaugZ0hJOP87nx1Dbss6OHPykxfpXe+Wn/CY03 vslbJaush9A7WFHq1LadqDOSaJ+qZZcgMCluduGVSiyFi82st8LFPRAHuZI+aiZYYa8a DNF6IOI4gKXwftQfk838rYzt1QeNE8iV6UqGBlZg+0cfMYi6zW6k4GDDC+nLRQykShSh vmaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jln7WuXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d3-20020a056a0024c300b006bd66ce21d9si1766938pfv.322.2023.10.17.07.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 07:18:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jln7WuXG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E0AA2801D666; Tue, 17 Oct 2023 07:18:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344066AbjJQOSO (ORCPT + 99 others); Tue, 17 Oct 2023 10:18:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343900AbjJQOSN (ORCPT ); Tue, 17 Oct 2023 10:18:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22C63F5; Tue, 17 Oct 2023 07:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697552292; x=1729088292; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Om9o9QaVlYqcLv+tCTlmT2MX/mZatt3OQzBysjJ7J04=; b=jln7WuXGteYKscIf3gXWXPx9jtfL8EUSHbub27qblZ14LrhWyYlPTkOV /CGjK3654XFpGELVX5gkzFQ1cgKzxa1bQ8i8P3I941oAvvfIcbyJr0uMX o6shPeF0Hsk/GDjihThAHumlBbQHtAG/W2EnRpvYW295X3/c5pwqENzd0 /T4s7hkdQZpK5hiVz9hkC+nPQuWHejJBBjVMGEc5otVW+apAkGRBx0LWn hbjamxp325m9icE7nHZJeeUVUs6LnJywVbuvakKCFBp84iV9h+uFYpSY2 eE5xC2ut2kO5jtc65FRr0wRPOzQYJsqTTLAXVfkpTv0jo+QLn42xY7O6J A==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="4389200" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="4389200" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 07:18:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="732736205" X-IronPort-AV: E=Sophos;i="6.03,232,1694761200"; d="scan'208";a="732736205" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 17 Oct 2023 07:18:09 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0BEC1193; Tue, 17 Oct 2023 17:18:07 +0300 (EEST) From: Andy Shevchenko To: Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Torokhov , Ferry Toth , Andy Shevchenko Subject: [PATCH v1 1/1] Revert "pinctrl: avoid unsafe code pattern in find_pinctrl()" Date: Tue, 17 Oct 2023 17:18:06 +0300 Message-Id: <20231017141806.535191-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 17 Oct 2023 07:18:20 -0700 (PDT) The commit breaks MMC enumeration on the Intel Merrifield plaform. Before: [ 36.439057] mmc0: SDHCI controller on PCI [0000:00:01.0] using ADMA [ 36.450924] mmc2: SDHCI controller on PCI [0000:00:01.3] using ADMA [ 36.459355] mmc1: SDHCI controller on PCI [0000:00:01.2] using ADMA [ 36.706399] mmc0: new DDR MMC card at address 0001 [ 37.058972] mmc2: new ultra high speed DDR50 SDIO card at address 0001 [ 37.278977] mmcblk0: mmc0:0001 H4G1d 3.64 GiB [ 37.297300] mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 After: [ 36.436704] mmc2: SDHCI controller on PCI [0000:00:01.3] using ADMA [ 36.436720] mmc1: SDHCI controller on PCI [0000:00:01.0] using ADMA [ 36.463685] mmc0: SDHCI controller on PCI [0000:00:01.2] using ADMA [ 36.720627] mmc1: new DDR MMC card at address 0001 [ 37.068181] mmc2: new ultra high speed DDR50 SDIO card at address 0001 [ 37.279998] mmcblk1: mmc1:0001 H4G1d 3.64 GiB [ 37.302670] mmcblk1: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 This reverts commit c153a4edff6ab01370fcac8e46f9c89cca1060c2. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index e2f7519bef04..e9dc9638120a 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1022,20 +1022,17 @@ static int add_setting(struct pinctrl *p, struct pinctrl_dev *pctldev, static struct pinctrl *find_pinctrl(struct device *dev) { - struct pinctrl *entry, *p = NULL; + struct pinctrl *p; mutex_lock(&pinctrl_list_mutex); - - list_for_each_entry(entry, &pinctrl_list, node) { - if (entry->dev == dev) { - p = entry; - kref_get(&p->users); - break; + list_for_each_entry(p, &pinctrl_list, node) + if (p->dev == dev) { + mutex_unlock(&pinctrl_list_mutex); + return p; } - } mutex_unlock(&pinctrl_list_mutex); - return p; + return NULL; } static void pinctrl_free(struct pinctrl *p, bool inlist); @@ -1143,6 +1140,7 @@ struct pinctrl *pinctrl_get(struct device *dev) p = find_pinctrl(dev); if (p) { dev_dbg(dev, "obtain a copy of previously claimed pinctrl\n"); + kref_get(&p->users); return p; } -- 2.40.0.1.gaa8946217a0b