Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4292531pxu; Tue, 1 Dec 2020 01:01:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYOs+zJOuGU3UElnNkPooFg5CmdwA6XDGhdfX5FlyXDCvqzxgQCKzLwwCSEUBb6crtsO1p X-Received: by 2002:a05:6402:88c:: with SMTP id e12mr2008292edy.88.1606813276620; Tue, 01 Dec 2020 01:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606813276; cv=none; d=google.com; s=arc-20160816; b=Q4MJiMJYfMK+qF/2TfW7bxxcd+XEARAHa7FeN0py7Wc/HtAgh3Z5pJQK92epwHWb3l HanQ3b7xIdSrAms4oMAVhMiOJtD19ECH6fyPkujpqDDs0RFMPOcxTmMD3JB1Pt6ZD4EM iTbNPiWsDUkqu2Ghpd3dHtXVeFh7lo2T7v3GmHX2ITYoysWH2MeYE09PvA1HASrMlgJK epPeqHh2l9HASY9qK8TLYYUExQ/1RGmswJgsmfrTJzH59sRDDrmAs5Yrzv0lWDyDdgmS /JqzjDGJ1Ihadr+PFZY2Yl7Y+tH+zamZvz5gZk3Ql9TZqddtSGkCYXoILEFG6KlsZsHO 9Mqw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ECp2no+/7yqlm+bkS4ScsVC975W2Byiumnja4c7NazI=; b=xxpq5fSmREGxFxve+ByNVuGPX+LGjfh9kMpto2PpXN9X5PyBSWHDYd4kXD1bcpsBij 35H6RCy4TnarhrXHmT2xxsWs7T/o1g/0iyjWYZzifoBb/qxtzGC13JyTzD7n1O3cQ4ch GEkzUbuoP01Yv2bAE0JQEJNod38/n0+rFdu1FQcxQWbqpV9vCLoorcSmNSr5PORkItzj LGHz0nn1BAalLYS1o3l11XBdFfCO6tBspvwISN5Ntfx/cOxrXc585IRkj2Yuv4p7SlbK wu7C9sGHEm7c3D66ZleJt7rcC2fLNPgPfp6zmvtQAyuIUBVwGoOBaJXHgtX/NUQNWj0I F02g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QZqJsvJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l2si517471ejf.667.2020.12.01.01.00.52; Tue, 01 Dec 2020 01:01:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QZqJsvJk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387881AbgLAI6H (ORCPT + 99 others); Tue, 1 Dec 2020 03:58:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:58602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387685AbgLAI41 (ORCPT ); Tue, 1 Dec 2020 03:56:27 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86B3022241; Tue, 1 Dec 2020 08:56:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606812972; bh=nvfC2AaiqXlne3luo+MKVTs7FVIBIkt5U5Pts3tq6eI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZqJsvJkw4QixHFx8hh1wFQRxiPyXeBUmV4NuBTF9m8MnIK7ybq+YS3gqza/KN8Bt kDf5M8zruQebsyuVvGdN5NkxWeITtBHL1b/lVgHrG8Vol8h9kndSEcn2WOxRHdkUy3 Gy4zrtEHPGxWCSRZxcKZiPqJNT9+6GhH3rjG/QhM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ahmad Fatoum , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= , Mark Brown , Sudip Mukherjee Subject: [PATCH 4.9 39/42] regulator: avoid resolve_supply() infinite recursion Date: Tue, 1 Dec 2020 09:53:37 +0100 Message-Id: <20201201084645.740577510@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084642.194933793@linuxfoundation.org> References: <20201201084642.194933793@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Michał Mirosław" commit 4b639e254d3d4f15ee4ff2b890a447204cfbeea9 upstream 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 Tested-by: Ahmad Fatoum # stpmic1 Link: https://lore.kernel.org/r/c6171057cfc0896f950c4d8cb82df0f9f1b89ad9.1605226675.git.mirq-linux@rere.qmqm.pl Signed-off-by: Mark Brown [sudip: adjust context] Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- drivers/regulator/core.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1550,6 +1550,12 @@ static int regulator_resolve_supply(stru } } + if (r == rdev) { + dev_err(dev, "Supply for %s (%s) resolved to itself\n", + rdev->desc->name, rdev->supply_name); + return -EINVAL; + } + /* Recursively resolve the supply of the supply */ ret = regulator_resolve_supply(r); if (ret < 0) {