Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2509121imm; Mon, 24 Sep 2018 05:40:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV61U0774racwHMGpUKOnlgY5AxBZJlI8CgTJXoBLfTenUZzAm1RSA9vrjOCXIPubDBebU9Mw X-Received: by 2002:a63:4281:: with SMTP id p123-v6mr9294254pga.91.1537792814018; Mon, 24 Sep 2018 05:40:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792813; cv=none; d=google.com; s=arc-20160816; b=Y0M88DGD+bEzrZmpjmTZluU7hohMoTIzb4AwWL0PnXKtID+2AxU2dJHU6yMVrVt9nm p1ceqi7IZ1n+YYgn9Qy+vY6zw3YzmgODiC5QuqGhXHHYqy/YVFqzSpGxbnY+a2XKfJtJ P0uXF78pjXTMPvTV7BWKUoUXdcelV+iyS33Fy6Fx7GE8e++TAgZrIpgQ0oUV/M/T7iPc cmH9ZoHc2QrdPvO/RoD1WV6SCiofN8pHERncnsrkhEEnjO93qItZMlEIY+NX2tVDKt00 CF/Q+ot8nZU5wUXDqSradR3AnGwy8aSzfHvg0L/d9oHKGtuj+xZgrvnP5n+7D3llK47e /RFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=SFSeCu76I6dqoXm5zZojYVbOMmcc0ty1bO3GnJ2OxAM=; b=Z1JUVtKEWnv6yub3pRJB4TkmWoJe3oA6WiKnh6Alx4L6wFxI2Kk/2UHufkLCO6Xhmr op6K2oZXqK/o3sMwj26/fCnlE1z3LUimepQzh1kToQ5JxEeWjSDg0zxWIl2LLnv2wlcA 5+B5Vzs3vydzdDMOJPV0zVv//NoEveKBjOAzRJXXinX4+49CQGq+EjaxFVShT4p93a64 0nizDahFzVgyMl/JhpfYj2ORHj4cb7TINoieI7a2Mh4GCW/B61sl1pKmEeDRs6zpoVsN fQky1zySXofbzLWl3FP+XxPL65jQ6PrJHRwWLVSYiDQsSHhyrgzZpFRy1pjFhQFoJI5o ST5Q== 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 a71-v6si4568587pge.281.2018.09.24.05.39.58; Mon, 24 Sep 2018 05:40:13 -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 S2387617AbeIXSkv (ORCPT + 99 others); Mon, 24 Sep 2018 14:40:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58768 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730741AbeIXSku (ORCPT ); Mon, 24 Sep 2018 14:40:50 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5A657107F; Mon, 24 Sep 2018 12:38:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Finn Thain , Stan Johnson , Frank Rowand , Benjamin Herrenschmidt , Rob Herring Subject: [PATCH 4.18 140/235] of: fix phandle cache creation for DTs with no phandles Date: Mon, 24 Sep 2018 13:52:06 +0200 Message-Id: <20180924113119.652905591@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rob Herring commit e54192b48da75f025ae4b277925eaf6aca1d13bd upstream. With commit 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()"), a G3 PowerMac fails to boot. The root cause is the DT for this system has no phandle properties when booted with BootX. of_populate_phandle_cache() does not handle the case of no phandles correctly. The problem is roundup_pow_of_two() for 0 is undefined. The implementation subtracts 1 underflowing and then things are in the weeds. Fixes: 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()") Cc: stable@vger.kernel.org # 4.17+ Reported-by: Finn Thain Tested-by: Stan Johnson Reviewed-by: Frank Rowand Cc: Benjamin Herrenschmidt Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/of/base.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -118,6 +118,9 @@ void of_populate_phandle_cache(void) if (np->phandle && np->phandle != OF_PHANDLE_ILLEGAL) phandles++; + if (!phandles) + goto out; + cache_entries = roundup_pow_of_two(phandles); phandle_cache_mask = cache_entries - 1;