Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp215311ybe; Wed, 18 Sep 2019 15:50:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMlOwIr8AkmoXdUGV+ZWgDnxe7QKRxi1kvtYpfTtR/SF3T0j+5S5tdST7P7GEV88aAgxNr X-Received: by 2002:a05:6402:128c:: with SMTP id w12mr6690379edv.158.1568847019739; Wed, 18 Sep 2019 15:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568847019; cv=none; d=google.com; s=arc-20160816; b=MzjbS6xdFcay5iA4O54I4OplghNZmhluU69IfSXoOGH1jg1PMyuRazLk02aBkIwSX2 XihtbYHdZaUTT/suUo9DPvw21StYm0BB7kuZ7RXj++2U/IBN7iaZmJr9N8dW/3uwN7ar VUrWxKUwrqXmSe9gVFXdqQIMoxHfzmMs46uVodx1SIDEHWWBluVFm3mBV/mgyoG2KTHN xjAPGcjr50Xu8FGTS4tWzZjeowKn2+Hp1hUfbd43dbprkFVY8WG14YstbAExMfch9xtz vVmNhVUf5YrLOmtzt4aIPgm/WYqKGVAmLu7l4hfsQzxaC+uB6oKIAY1FOkWSCaUUGiYQ 6QKg== 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=8VYmjtiZYI838VU/pBSxIaCrbL4wUGT5dAymsJ7z3eE=; b=gvQo8en8AP8RB8VunEcMd8de6mI4PfRcXRnxZ0EvkC9gIjkPlHvx/B7XLiHh7MyhY2 bvx8y36GSic77HNlDH63i+Lf2MPWcbgRiC29tEtlKbbcxSvZ/KvRCcNSfB9s95mvSbcV 85if2ORKqAnvmfswJpovJNGE3NOzN/phqJKf43nKfoxxpo9+WToos4v5B87FrnOn4rVn EMcDyEC2xiglf+cEz/mjoOfy2O/xmzbAJEMIw4nVRWFVNnYs+3meN9NUgzkbqHoqUpWg ON2Q9VU6NkS4H2weMBQK418BGCYSNGHuZgVmy305c1WENu53smWNsHgW5UVhOKrFQNFw PlPw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si3488603eju.120.2019.09.18.15.49.56; Wed, 18 Sep 2019 15:50:19 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729203AbfIRUUE (ORCPT + 99 others); Wed, 18 Sep 2019 16:20:04 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:37979 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbfIRUUD (ORCPT ); Wed, 18 Sep 2019 16:20:03 -0400 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAgQe-0000Mf-W0; Wed, 18 Sep 2019 22:19:56 +0200 Received: from ukl by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iAgQc-0005uR-DN; Wed, 18 Sep 2019 22:19:54 +0200 Date: Wed, 18 Sep 2019 22:19:54 +0200 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Rob Herring Cc: "devicetree@vger.kernel.org" , Geert Uytterhoeven , Will Deacon , Joerg Roedel , "linux-kernel@vger.kernel.org" , "linux-mediatek@lists.infradead.org" , "kernel@pengutronix.de" , Matthias Brugger , Geert Uytterhoeven , Marek Szyprowski , Frank Rowand , Peter Rosin , "linux-arm-kernel@lists.infradead.org" , Robin Murphy Subject: Re: [PATCH v2] of: restore old handling of cells_name=NULL in of_*_phandle_with_args() Message-ID: <20190918201954.2phyqxqhoj5jwklt@pengutronix.de> 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: User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 18, 2019 at 03:09:06PM -0500, Rob Herring wrote: > On Wed, Sep 18, 2019 at 3:47 AM Uwe Kleine-K?nig > 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(-) > > Can I get a proper patch please. I don't understand what is wrong with my patch. Can you please expand what you are missing? I just tried to git-am it and the result looks fine. Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |