Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3395788lkq; Mon, 23 Nov 2020 04:45:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/CAGVu7oWuHMuYGXVwpfrtyjCJDC7T3LyNWHUebrHNcCJjhuh01c5ePfviI+JAQh3jNAE X-Received: by 2002:a50:9ee4:: with SMTP id a91mr29742494edf.121.1606135534978; Mon, 23 Nov 2020 04:45:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606135534; cv=none; d=google.com; s=arc-20160816; b=F95O9V9mQmaeUikuVmGbCVoW1DF6+IZoz5BmYohz6CRdmxffdOVDYZ4MjwuFud80Ib 0jAtVYyoFB+kSHNSAWwUEVFbvwGBWs3F33Ucbxa6O/Zbrl2yuFCfAezLLTfKn38yVE8n sUAyVN7u8YotISfG/J+Dac9JvMLXjd4LM5cDE8J/OvoVbvCBSYaQ3t04XQ9u3TRCa5mG 9q2a0xE1BrwdffnY+HNa+q07nnSKPuyHcGpeRSQPgPHOeVKKAHLCEN6HzYTk68gsdgps Rt5LjQlSOf7DI1Lxx4oaGVWxFrdujNjCviK0UvvJE0iAbfZ8CwAC2rhAFoEzGkVnYKCK sT+A== 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=Ny1X9qCpr26ru7Rt8laSWC/gjVMfOHOaXvo+gKNYDfA=; b=Vf6AfFiS8zfvnIK3eoPnSd2lGn0FBATR1Zt6G1rp6BKTQ9EkduIeRYf6dBiMmbDwtz sLb20cmTpYhgIpUDfyi345gasUHt5j7xBKC/BhjhWIXDw1G77wGvapmbg6EvTiSeY8Tr XxQd4ly1DZhmaXu5CMn6ElPkcgqgkSRHzoPyZ9kgxzDIiyrHqv+kEFHr8/zGcjODiL+A 5pjsN1SOIKFK5CmL2fsXkj+U2+JWJsUFRXvG9XHh0oE2xBA/wlX+bBbsm4k7Yzbiv8/R EkP/5piJnWDnMFMWjQKC/BPsqmT3giXrYeRNqf/Z5h784IQn5nMIgNdZc1Dj+kVHCa6G zvgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LIDhreyU; 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 dx21si7315672ejb.627.2020.11.23.04.45.11; Mon, 23 Nov 2020 04:45:34 -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=LIDhreyU; 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 S1732390AbgKWMj7 (ORCPT + 99 others); Mon, 23 Nov 2020 07:39:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:52728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732377AbgKWMjz (ORCPT ); Mon, 23 Nov 2020 07:39:55 -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 569F220857; Mon, 23 Nov 2020 12:39:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135195; bh=zwBQ3BKA4R2yhDU/TO/u//Nnyqnb33oJxj9u9oogg64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIDhreyUoot85OJe0PlC5778ZdkwoNcdNTDRjiHkXwotmBzURtP8pTnIsGhqIYj3Q K4QtN/FXNSaWeCPTaUlnPjR3yfbBIDqmkB51uB8vxKwsar+N2oMvo+JRHIIe9OgXom YrOmFS+iiu5a6CmJWR5X3cP4O5DLKBj8uTw5KpJE= 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 Subject: [PATCH 5.4 139/158] regulator: avoid resolve_supply() infinite recursion Date: Mon, 23 Nov 2020 13:22:47 +0100 Message-Id: <20201123121826.640186680@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@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 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 @@ -1800,6 +1800,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; + } + /* * If the supply's parent device is not the same as the * regulator's parent device, then ensure the parent device