From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 2FB63C5519F for ; Fri, 13 Nov 2020 00:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6D9E22241 for ; Fri, 13 Nov 2020 00:16:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="E2VXw3pH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726148AbgKMAQ4 (ORCPT ); Thu, 12 Nov 2020 19:16:56 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:58777 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726041AbgKMAQw (ORCPT ); Thu, 12 Nov 2020 19:16:52 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4CXJtV3P4WzZx; Fri, 13 Nov 2020 01:16:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1605226610; bh=v/N+ke/pAmzjcPwPxtjEP2gk5NrcB9U2EpCsm2ZUup4=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=E2VXw3pHSyNHddidLaJ6ET8ftTfWSuB/JiQU8MG+So+i6bwXxTJfzlPdhoaC+VJPR nfYng5wBIWDvDHFJrEBNtVbpOe73+mpweR2WHCo5tIrzmK8f5P682BzTNrKN+24kFv KorNApxtuWx42fkHHDqDcM3K0TNdWEwypeBX8G2/9Fe4dQm2aU3gIRYYsfbFyGBiBE aAr/6i/Wk3nMXhvDcBFSYhrW0yILHkl6pFqRU1KD/2KXNoYDPHl5tJgWZu87W4HtM5 /iUunAvCZv9V3TZMV/msjnCxlsr03VirHwU9W7N/g2t7AQ/y7T5lmqn37QWUVQEr2x Az4vNGbgvL/tA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Fri, 13 Nov 2020 01:16:49 +0100 Message-Id: In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 3/4] regulator: avoid resolve_supply() infinite recursion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Liam Girdwood , Mark Brown Cc: Ahmad Fatoum , linux-kernel@vger.kernel.org, linux-arm-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 -- 2.20.1