From patchwork Fri Nov 13 00:20:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11902325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_ALL,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4765CC2D0E4 for ; Fri, 13 Nov 2020 00:21:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDB7921D79 for ; Fri, 13 Nov 2020 00:21:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Y7agey3Y"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="X7fewpZi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDB7921D79 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References:In-Reply-To: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=270UItrn1QjIYAl0Zh1evCAfDX24XM4cALytCTZ53TE=; b=Y7agey3YQp+qZ26hwptdyl7ko VEYEZ4ppAUlPDCFmMt3wsuFCsAMmu1arx8p/HdABF8kYngi3ELreAhbQiclGgwirtoLnf1n9V0lnY EYZlM85q73kwzCiE0T+JSf2/3LENB2yYTmJfhQZupD61PQcSyuF1v6foS+a6rrdxAwlri92QEDpNX xRFzfaIOoblmYglN7gwvN1jHNE6TJea/kYOGzwanyx4pVSZbrA3MQ3yWjLFNGh349tdBou9j7ikR/ yLaD6TnDP+N59bSWwiYl5A8vUN2jjOsOcHUVHv4fEqI32byVZ2klJepQ0i5e1csTXUozhSEyLh6So /h6cTQSAQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpT-0001W2-3i; Fri, 13 Nov 2020 00:20:39 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpM-0001T5-I9 for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 00:20:33 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4CXJyg2XHyzKj; Fri, 13 Nov 2020 01:20:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1605226827; bh=V7HSPNSozpIXr1ujMh8djMuILzn4otXrS7tNpH0CxW8=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=X7fewpZiLRISra8a+7M37SslDkjSNvkIQwAyr001ioILw7vku+3wcym9IFFyz6JL0 LaNKuodVX//mrqARlbvvAAuQrnvdl4S7azcJgDy6GvW8ikcyAFdREIpscdRicLahCG JLZo/VUcXrzJuxNdNpDngzfVYRxtqupzN7+rpZlhMp6kXnnfhvZ0pRnLjZffTcmpYz gjdd0CpaIjQdhoP16NVl2nfBd4QERSlhGl7xubWOliVcJy1alS9ntqn+4WBAlLAPZd QW9ozJZWRpDPZK7AsebSjZiWzL3RcmfFYcBEj/tx/KHUwP+ObNlJQBuC1rBK2nahe+ BwHSRjRrfFgWQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Fri, 13 Nov 2020 01:20:27 +0100 Message-Id: <78c3d4016cebc08d441aad18cb924b4e4d9cf9df.1605226675.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH RESEND 1/4] regulator: fix memory leak with repeated set_machine_constraints() MIME-Version: 1.0 To: Liam Girdwood , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_192032_754876_B4F61CFF X-CRM114-Status: GOOD ( 16.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Fixed commit introduced a possible second call to set_machine_constraints() and that allocates memory for rdev->constraints. Move the allocation to the caller so it's easier to manage and done once. Fixes: aea6cb99703e ("regulator: resolve supply after creating regulator") Cc: stable@vger.kernel.org Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2e1ea18221ef..bcd64ba21fb9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1315,7 +1315,6 @@ static int _regulator_do_enable(struct regulator_dev *rdev); /** * set_machine_constraints - sets regulator constraints * @rdev: regulator source - * @constraints: constraints to apply * * Allows platform initialisation code to define and constrain * regulator circuits e.g. valid voltage/current ranges, etc. NOTE: @@ -1323,21 +1322,11 @@ static int _regulator_do_enable(struct regulator_dev *rdev); * regulator operations to proceed i.e. set_voltage, set_current_limit, * set_mode. */ -static int set_machine_constraints(struct regulator_dev *rdev, - const struct regulation_constraints *constraints) +static int set_machine_constraints(struct regulator_dev *rdev) { int ret = 0; const struct regulator_ops *ops = rdev->desc->ops; - if (constraints) - rdev->constraints = kmemdup(constraints, sizeof(*constraints), - GFP_KERNEL); - else - rdev->constraints = kzalloc(sizeof(*constraints), - GFP_KERNEL); - if (!rdev->constraints) - return -ENOMEM; - ret = machine_constraints_voltage(rdev, rdev->constraints); if (ret != 0) return ret; @@ -5146,7 +5135,6 @@ struct regulator_dev * regulator_register(const struct regulator_desc *regulator_desc, const struct regulator_config *cfg) { - const struct regulation_constraints *constraints = NULL; const struct regulator_init_data *init_data; struct regulator_config *config = NULL; static atomic_t regulator_no = ATOMIC_INIT(-1); @@ -5285,14 +5273,23 @@ regulator_register(const struct regulator_desc *regulator_desc, /* set regulator constraints */ if (init_data) - constraints = &init_data->constraints; + rdev->constraints = kmemdup(&init_data->constraints, + sizeof(*rdev->constraints), + GFP_KERNEL); + else + rdev->constraints = kzalloc(sizeof(*rdev->constraints), + GFP_KERNEL); + if (!rdev->constraints) { + ret = -ENOMEM; + goto wash; + } if (init_data && init_data->supply_regulator) rdev->supply_name = init_data->supply_regulator; else if (regulator_desc->supply_name) rdev->supply_name = regulator_desc->supply_name; - ret = set_machine_constraints(rdev, constraints); + ret = set_machine_constraints(rdev); if (ret == -EPROBE_DEFER) { /* Regulator might be in bypass mode and so needs its supply * to set the constraints */ @@ -5301,7 +5298,7 @@ regulator_register(const struct regulator_desc *regulator_desc, * that is just being created */ ret = regulator_resolve_supply(rdev); if (!ret) - ret = set_machine_constraints(rdev, constraints); + ret = set_machine_constraints(rdev); else rdev_dbg(rdev, "unable to resolve supply early: %pe\n", ERR_PTR(ret)); From patchwork Fri Nov 13 00:20:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11902327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_ALL,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0D8C2D0E4 for ; Fri, 13 Nov 2020 00:21:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C124220A8B for ; Fri, 13 Nov 2020 00:21:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Kgmeadkc"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="p9UzMwxt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C124220A8B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References:In-Reply-To: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xOpOoAeq0r8JThUOVIwURPUhpBZfdlLb6zdD+1T1ikM=; b=Kgmeadkcdz43d3W8Mw5h68j/K bByGmVf5NPZsmnhYnIpgW7sG+6RWt7M7Imr0PmACScOxFr3Q68S3r5tLtDksjlKMTvPfG37K4huWJ alHboM8Rk6CUuVsalCAjZl1sMyNOwrT+BbBQ75GeBAYCBYMXe8zYIgGDjclgoJjoLUZRHpTNARxV7 52WtVL3Ucjzyppxt3fYXLxs054XkwPnvR/MKx+1E3I5BcAo4AJwonfVnTSZzsSPRTfuC6mTflV7FY LJ2kwbV0fzET20xzj3slVhmLWBFuefeXZBZl87REFCJmO+4PrLonvA0IvN3FC2BbWuOgnoj5GQkkS uRKN6YrPw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpY-0001Wo-Jv; Fri, 13 Nov 2020 00:20:44 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpM-0001T6-Mz for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 00:20:35 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4CXJyh0FNGzKw; Fri, 13 Nov 2020 01:20:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1605226828; bh=DQRcuEJmpEK6o+KN0OiQBuiYhpkks7VZqxdk2Ek0AWU=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=p9UzMwxtzT4ZcN6g65oZQDvCBwJ3whwWsDb+81YPMHLMOsyFvw9cGeBZdZnMLfk8Q bbqTWjN14DnCiSHjazEBXRTiJyXJD4SS/3loJRrXRnUEM3jrGjNnaAeW1RqPZlL9AI LqlNumry4QbfrsDlrjCHy7YT3q1G2+9ytF140OCkO3QCWbK4GCkB4F0IHah51Xh+x9 fh+MtiDaCUjyIyghZlpF18BOaYgGzs+dYT9xw1nXxeiu5yEzw7SkIMClGCnb4ZGn0j KlpCkDVJdhPZzyV1848xUpxF37DM40c7UqavvpNWx/VdFhuk2eiI19K4sX3b1ugQbE ox72bn/FfmmuA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Fri, 13 Nov 2020 01:20:27 +0100 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH RESEND 2/4] regulator: debug early supply resolving MIME-Version: 1.0 To: Liam Girdwood , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_192033_017993_AC335D1C X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Help debugging the case when set_machine_constraints() needs to be repeated. Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index bcd64ba21fb9..ad36f03d7ee6 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5296,6 +5296,8 @@ regulator_register(const struct regulator_desc *regulator_desc, /* FIXME: this currently triggers a chicken-and-egg problem * when creating -SUPPLY symlink in sysfs to a regulator * that is just being created */ + rdev_dbg(rdev, "will resolve supply early: %s\n", + rdev->supply_name); ret = regulator_resolve_supply(rdev); if (!ret) ret = set_machine_constraints(rdev); From patchwork Fri Nov 13 00:20:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11902323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_ALL,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 470F4C5519F for ; Fri, 13 Nov 2020 00:21:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFFE122252 for ; Fri, 13 Nov 2020 00:21:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YlOQwFb5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="P4toRVJh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFFE122252 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References:In-Reply-To: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fyeqUq9gXkRgDCYxBZbsITeqXLIBVFrgpPng6/bT/B0=; b=YlOQwFb5poack7m99GM5uYR1b poylLvc3GYAnxWTCE0fmXiQFkRHoPxY+XEnmpktL0jTmqm88E47fgIMwD43GS1iUQ0HnwiyFrK1ta Fkhu2vVjEKS9ZnM34G+zA/nUTxEvcWAFdE5mIX1FvhD8aN4pFKi9rbcVB2fFOSv7hzdpY+BDEd2hf 3JQl7+0IqnROxAC2JaOfCrmQiAiSSuR+HJMCKXjga//Y7jz14D1mQks6DQHSFY8EeRuGbrgw/HbTw gRZBPFrWrXwaQCb8gxSOxS3w4QUDhn6TAaRDZHebNYRIdXhsqJJ50yfyGDiusKM2SPP0BXY2PQNqp Ms3HSEHyg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpa-0001X8-AY; Fri, 13 Nov 2020 00:20:46 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpM-0001T7-Ld for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 00:20:35 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4CXJyh3sdQzPG; Fri, 13 Nov 2020 01:20:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1605226828; bh=v/N+ke/pAmzjcPwPxtjEP2gk5NrcB9U2EpCsm2ZUup4=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=P4toRVJhjTSlN3ZbQf15Vjex+ZCE/OjDa1oHj/A3Lm1pH+vfcU971wCUB5E2nBVSM ZMjFG1CjHLAFCQifOItDmuRN8G+2+tHwQFMukVmWiWPkFPmmswG1913YLtWUL4Vl3Z bV4va4iW6y/j7NQHQKIgYQ/B2NneucgucD8o9nqcHEfHVXUXDqd/TbZMwuWSuiIi3y jr0tD7vW1nuTXmyyUvy4FJvEcZU6kuCPlluCFC2ZNtXZgVgus54JLdKKgHdiqF7Oiz wPDTmBGX7DxgRAz9UEGnceWICqHu0BhnLI8C7Nv+gEB2hCt0hNvT7/ZNOSl1+VxfjA rGVK5KYDIprdw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Fri, 13 Nov 2020 01:20:28 +0100 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH RESEND 3/4] regulator: avoid resolve_supply() infinite recursion MIME-Version: 1.0 To: Liam Girdwood , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_192032_923097_31341B4C X-CRM114-Status: GOOD ( 12.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When a regulator's name equals its supply's name the regulator_resolve_supply() recurses indefinitely. Add a check so that debugging the problem is easier. The "fixed" commit just exposed the problem. Fixes: aea6cb99703e ("regulator: resolve supply after creating regulator") Cc: stable@vger.kernel.org Reported-by: Ahmad Fatoum Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ad36f03d7ee6..ab922ed273f3 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1841,6 +1841,12 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) } } + if (r == rdev) { + dev_err(dev, "Supply for %s (%s) resolved to itself\n", + rdev->desc->name, rdev->supply_name); + return -EINVAL; + } + /* * If the supply's parent device is not the same as the * regulator's parent device, then ensure the parent device From patchwork Fri Nov 13 00:20:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 11902329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_ALL,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA8D4C2D0E4 for ; Fri, 13 Nov 2020 00:21:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 413DE20A8B for ; Fri, 13 Nov 2020 00:21:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ck0VlXc1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="VSygM+O3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 413DE20A8B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rere.qmqm.pl Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References:In-Reply-To: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rm+k5Px8efGjKpBYM+n4NdWkyXVwYby9xboCgacUaMo=; b=Ck0VlXc15ncK5QX9pv54XBRP2 MCgA5wAym7DKUfJ6H0MwTndRnVFW/5YMfE5rqqSQIjGQZyPfJdW5bPlBktu+ti8xrs4f71EYqF+a9 YW28dB9TbwLj+ozFfZwZ1JvDKw79wLyS6lD58bdSWAychBkjoh7unS6PY5yNFukVjVDxSKUO5ptnZ RyyiYCuLeipJde1eD0m4JCwrId1oU34pER9Y5Hpe99WkwXApoQ3fR4H4j1DYLtwIX+yc3zQSQNSFp 5H4QF7rZJRmtLqQ30PUuQkTS58jaJth1BWiwh71ewW9UoDyvBKMDvggadCsWO3BBDO7nulDzyR+VL nnv9MV4BA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpP-0001V3-Uo; Fri, 13 Nov 2020 00:20:36 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdMpM-0001T9-KR for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 00:20:33 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4CXJyj0dJVzSq; Fri, 13 Nov 2020 01:20:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1605226829; bh=GU5qJ1nTeXHIDvDBgFSSbRsT2IkPhz3ghAkGAasa5UQ=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=VSygM+O351lVRtDnV3l8XYihCzo7dw0YmgB/qdfCKlhUgrWMdEdMZoWwaqMrD/P6R GhAAzBtFyYDb7sMWC6owOnye3rI0dqOWdGb0Q4pm5ytwiGo6kCzHa7e9dp+DOq9ejs W9YTW+JOekeAn1RPTEfjfDpApVsbZFeyW+tmK2iHSghSP1MJfs4/R9CVgSUfhOqpWE E1tA96p5tOgeVGZ0iRZiCgj4cMk0pQrpL0BdbRaz2Jim1LYqQZE4ZruSLsEktZhCMx Quc7y6bg7SatLm4TUggkpgE9ORifDGmynlOh9iVx1AE3CARMs/7cqaUC22YkPID8V4 IJk5kqlyIfiZQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Fri, 13 Nov 2020 01:20:28 +0100 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH RESEND 4/4] regulator: workaround self-referent regulators MIME-Version: 1.0 To: Liam Girdwood , Mark Brown X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_192032_877682_D4726A67 X-CRM114-Status: GOOD ( 11.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Workaround regulators whose supply name happens to be the same as its own name. This fixes boards that used to work before the early supply resolving was removed. The error message is left in place so that offending drivers can be detected. Fixes: aea6cb99703e ("regulator: resolve supply after creating regulator") Cc: stable@vger.kernel.org Reported-by: Ahmad Fatoum Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ab922ed273f3..38ba579efe2b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1844,7 +1844,10 @@ static int regulator_resolve_supply(struct regulator_dev *rdev) if (r == rdev) { dev_err(dev, "Supply for %s (%s) resolved to itself\n", rdev->desc->name, rdev->supply_name); - return -EINVAL; + if (!have_full_constraints()) + return -EINVAL; + r = dummy_regulator_rdev; + get_device(&r->dev); } /*