Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp980670ybe; Thu, 19 Sep 2019 06:57:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzohc4wGIZFGDb693aS/UU3U8WOwnEUv28mvtyU3LWA2TfnhT6KlpWPAzD0QLUGzyrwwrrI X-Received: by 2002:a17:907:211c:: with SMTP id qn28mr296421ejb.244.1568901426337; Thu, 19 Sep 2019 06:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568901426; cv=none; d=google.com; s=arc-20160816; b=uo6E7c3IHnPjuAawf6dIVqAVzpYmwUYfUpM6bRErh8nYQHmOxlBoUdB7S8cwLap3oX XSEa6ZcWmpOHr09xS8rrb6OegyUpm2QTkUjBtT6xnhROObDVJIECkJ74+x5h51tqq1oQ WJ3NmvTdRj83uMnLou2xrqmBukT7VNXmnLZGfb3lqqeFkAI+9Hxd6D3E9oTZJNtExq8n RDoC6evFoe6PZDLuXjXAcbkDvla5/L8Cabyi1qoVuRc5zjeBjRFLK5ZKFGToHiWfrBYC 8B0gnTnlbIl8rbF6KiIaYMZTzXnEMDyrQxQAK3vjjUf1xXAJHn6sameevTQlmGDAnR90 +jEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=6Vbzint3TNkF0RwuJRnvSz0zFNi0mSUxmrLncCYz9Sc=; b=AIbWtiWgNrSIw1vdJbVBMGGYiGz+jSQT0SQxOYLcNycqmwdrp+C5ScoLHKBi2QYF66 abiK0orFlxfY1hF2XIA5MVVx6Ng212tMInkXYJy4KNxPyXJdghoVzW8iWoSsbjjtAO2V nhCuRBScbkOfJpNsxvmSjbDXT5yv52cIHtYOFgnpsaMvxg2ZLRonHoGFPY5ZEYfRBKcX 0gFDKpZiI41ejEQGCqhBWcLKlyrhBihnCliwaG9h7UIaa7lHCp6HU+Z3RqXo/4Z6iwK4 lCTNdfupqY5iifqWGTza/t/JdrevsAWUGzkOtQQ8ySTO+UTxJ8oPfAeLWEOGqaKZh1BI mLlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e22si4460778ejx.107.2019.09.19.06.56.42; Thu, 19 Sep 2019 06:57:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390170AbfISNcp (ORCPT + 99 others); Thu, 19 Sep 2019 09:32:45 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:34604 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390044AbfISNcp (ORCPT ); Thu, 19 Sep 2019 09:32:45 -0400 Received: by mail-oi1-f195.google.com with SMTP id 83so2747018oii.1; Thu, 19 Sep 2019 06:32:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=6Vbzint3TNkF0RwuJRnvSz0zFNi0mSUxmrLncCYz9Sc=; b=OV6EVrlTMNweLWfFFk/d7AqbBHbtp8fHoNhSSqrGUc4RxoTzD6a4217jslhB+HBSQK KX1SA2V6weBpFD4AacseJILPD98S8ktAw9ys2k19bBnJQ1lkVPVflEUuMecDmLzDejlF 3FhrB5LMUFeB/N9c+Kw6LpooC1IZw+GJzMVUbkAd2BWSHsCfnhyg4idtS5zDDQQMxM/T CFlK/v+jSEglRDyKpIr+kTWrHc7sE2eWo+REC2YDf0qAxBVABJcR5VKIsHhAFdG3tWq8 N0VjCItt4wt3xlSmLo1L0bBiL5jo95eIcPhrghfe0UgjEiDI/97E+FJ73JyBMzeDnP0Z HmJw== X-Gm-Message-State: APjAAAVl9RJiGon7LJnLnb5fwz06ilv/mU5Stk+kvnHwYzGVJHCCifv5 zZUJcOZUz1kGINokcitpnw== X-Received: by 2002:aca:dcc4:: with SMTP id t187mr2208633oig.136.1568899963907; Thu, 19 Sep 2019 06:32:43 -0700 (PDT) Received: from localhost (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.gmail.com with ESMTPSA id 17sm482618oiz.3.2019.09.19.06.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 06:32:42 -0700 (PDT) Date: Thu, 19 Sep 2019 08:32:42 -0500 From: Rob Herring To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Peter Rosin , Frank Rowand , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "kernel@pengutronix.de" , Will Deacon , Robin Murphy , Joerg Roedel , Matthias Brugger , Geert Uytterhoeven , Marek Szyprowski , Geert Uytterhoeven Subject: Re: [PATCH v2] of: restore old handling of cells_name=NULL in of_*_phandle_with_args() Message-ID: <20190919133242.GA27990@bogus> References: <20190918063837.8196-1-u.kleine-koenig@pengutronix.de> <20190918084748.hnjkiq7wc5b35wjh@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190918084748.hnjkiq7wc5b35wjh@pengutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Sep 2019 10:47:48 +0200, Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= wrote: > Before commit e42ee61017f5 ("of: Let of_for_each_phandle fallback to > non-negative cell_count") the iterator functions calling > of_for_each_phandle assumed a cell count of 0 if cells_name was NULL. > This corner case was missed when implementing the fallback logic in > e42ee61017f5 and resulted in an endless loop. > > Restore the old behaviour of of_count_phandle_with_args() and > of_parse_phandle_with_args() and add a check to > of_phandle_iterator_init() to prevent a similar failure as a safety > precaution. of_parse_phandle_with_args_map() doesn't need a similar fix > as cells_name isn't NULL there. > > Affected drivers are: > - drivers/base/power/domain.c > - drivers/base/power/domain.c > - drivers/clk/ti/clk-dra7-atl.c > - drivers/hwmon/ibmpowernv.c > - drivers/i2c/muxes/i2c-demux-pinctrl.c > - drivers/iommu/mtk_iommu.c > - drivers/net/ethernet/freescale/fman/mac.c > - drivers/opp/of.c > - drivers/perf/arm_dsu_pmu.c > - drivers/regulator/of_regulator.c > - drivers/remoteproc/imx_rproc.c > - drivers/soc/rockchip/pm_domains.c > - sound/soc/fsl/imx-audmix.c > - sound/soc/fsl/imx-audmix.c > - sound/soc/meson/axg-card.c > - sound/soc/samsung/tm2_wm5110.c > - sound/soc/samsung/tm2_wm5110.c > > Thanks to Geert Uytterhoeven for reporting the issue, Peter Rosin for > helping pinpoint the actual problem and the testers for confirming this > fix. > > Fixes: e42ee61017f5 ("of: Let of_for_each_phandle fallback to non-negative cell_count") > Tested-by: Marek Szyprowski > Tested-by: Geert Uytterhoeven > Signed-off-by: Uwe Kleine-K?nig > --- > > On Wed, Sep 18, 2019 at 08:01:05AM +0000, Peter Rosin wrote: > > On 2019-09-18 08:38, Uwe Kleine-K?nig wrote: > > > EXPORT_SYMBOL(of_parse_phandle_with_args); > > > > > > @@ -1765,6 +1779,18 @@ int of_count_phandle_with_args(const struct device_node *np, const char *list_na > > > struct of_phandle_iterator it; > > > int rc, cur_index = 0; > > > > > > + /* If cells_name is NULL we assume a cell count of 0 */ > > > + if (cells_name == NULL) { > > > > A couple of nits. > > > > I don't know if there are other considerations, but in the previous two > > hunks you use !cells_name instead of comparing explicitly with NULL. > > Personally, I find the shorter form more readable, and in the name of > > consistency bla bla... > > Ack, changed to !cells_name here, too. > > > > > Also, the comment explaining this NULL-check didn't really make sense > > to me until I realized that knowing the cell count to be zero makes > > counting trivial. Something along those lines should perhaps be in the > > comment? > > You're right, I extended the comment a bit. > > > But as I said, these are nits. Feel free to ignore. > > I considered resending already anyhow as I fatfingerd my email address. > this is fixed now, too. Additionally I fixed a typo in one of the > comments. > > Thanks for your feedback. > > Best regards > Uwe > > drivers/of/base.c | 35 +++++++++++++++++++++++++++++++++-- > 1 file changed, 33 insertions(+), 2 deletions(-) > Applied, thanks. Rob