Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2442611rdh; Sun, 29 Oct 2023 17:03:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5fDG/ebZrtKCXeVQ7qJn8Tcsvl9fOrWnrQMGRgrH0f3iIdVjiuZ9ToeFQm6V6wGnh4gS0 X-Received: by 2002:a05:6a20:8e1f:b0:174:210c:34b0 with SMTP id y31-20020a056a208e1f00b00174210c34b0mr8031941pzj.0.1698624193121; Sun, 29 Oct 2023 17:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698624193; cv=none; d=google.com; s=arc-20160816; b=Iv1nOBrtSD0TrtlJdWiuSRKDFRT7jeJVHOm9uMSzLSFXlBUP5XJ1TLyzOLRDvVWxi3 odWt+LSiT3ztC8OvhP24Tw4geWh4Qa9q1coxHS6IfqaVAuVh7smcQi2lHxgDfGr8Z0Wv pQENUZv7o6NLTrPN71+3s4SupiempsoWUcTEJDTUo8jk0xQL7dPQtPGPnKsCq30wRQG1 Ife+w2lYF9E0MdumZT6J5J/kjV3YwEqiI3iJ9n+OvHBjxTNrzmjlQVQyY+diFmuQ1y3u MZJ2RjndsIIizmeGxQ4PGqYF8oiNgtLXvgMc0tx+1/mm5xifwPsTISXmv9/WaJ+ljFgR yxuQ== 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=ClXWnZM8dJGD5vWzw+h4OPz/TuG+sUwrdHl0c7gtLiI=; fh=I8IGDf8gTqT1JLnaKZbtcqlO3iCBjm0oIeyZ54ulJvw=; b=ySEOSxSEzqc+Tt8uLHjwcTY33M5oFzpQE+/tX/CSNPecFaCCoeLtPUwD6CKYRAfu7L YBs/SU8QByPl+Oz71Ze5HeLYwEFxMP2qEXa9hwFJbkfsSjCuH5oqul9yPzYA1Un96qQX EVeJ2Yyd0K39HR3tQSCoBto17fWkf5Kj0E2afjQXYSqpUPHO0w2XmaKPamYSmzvoGJXg yoc6oYp2CyeKrIsICYA4EaO/7H8EafrxK/qLVML65czrUFY/6fiYGSATumA+HwbTsVEv iEIuy1Y5eij0yfvX/jIsbHsG1QY9HCtCHrMrueEonn0ZkrPAF13ysPFFeHqUHBNShGoQ QVIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Aq8DlL55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bs68-20020a632847000000b005b7c45b1f95si4077788pgb.555.2023.10.29.17.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 17:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Aq8DlL55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9165C8057459; Sun, 29 Oct 2023 17:03:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbjJ3ACm (ORCPT + 99 others); Sun, 29 Oct 2023 20:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbjJ3ACg (ORCPT ); Sun, 29 Oct 2023 20:02:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F89110C8; Sun, 29 Oct 2023 15:57:55 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A1BBC433B6; Sun, 29 Oct 2023 22:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620225; bh=quEiwnh0HWwxQJhsPx6tXqzN6tx0b2hgZcdHoPkuRJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Aq8DlL55Cs4OCyyynaq5Kp6zNME7yhllx5ZmLFIdfqc1+NO4MTnevhzzsObKIxRji pq1KNX9FBAyCBm5m0QBYPczQpZzLp2/JRJRexzXa+ECY8eFI2NBQYMUQB39a3lVSDL ZMv+pALhNcppmUtXntxpGjKyP+jMA8SsebRp7wEImhb8GhOUudIOGf6EIzs+/V/B6d AVR+cHaexC6EZkXHArkDEJfySRBJ81AochyeC4m4Opr7Oglgtfns1U0DchP9Qp+r4x uCQm8mYbGiwzd2icIgDjF/cWOodlw83S3HVI/ox65S6KiThXyI8fTka1duHkDOTuuu 3zkTEeXqUZSCA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andy Shevchenko , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 6.5 51/52] Revert "pinctrl: avoid unsafe code pattern in find_pinctrl()" Date: Sun, 29 Oct 2023 18:53:38 -0400 Message-ID: <20231029225441.789781-51-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231029225441.789781-1-sashal@kernel.org> References: <20231029225441.789781-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.9 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 29 Oct 2023 17:03:08 -0700 (PDT) From: Andy Shevchenko [ Upstream commit 62140a1e4dec4594d5d1e1d353747bf2ef434e8b ] 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 Link: https://lore.kernel.org/r/20231017141806.535191-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- 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 b84781cfc2596..401886c813449 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1012,20 +1012,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); @@ -1133,6 +1130,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.42.0