From patchwork Wed Apr 5 10:32:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 96835 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp196601qgd; Wed, 5 Apr 2017 03:35:06 -0700 (PDT) X-Received: by 10.99.65.1 with SMTP id o1mr29628909pga.93.1491388506326; Wed, 05 Apr 2017 03:35:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si20203815pfi.300.2017.04.05.03.35.06; Wed, 05 Apr 2017 03:35:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933473AbdDEKeb (ORCPT + 6 others); Wed, 5 Apr 2017 06:34:31 -0400 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35871 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933479AbdDEKdZ (ORCPT ); Wed, 5 Apr 2017 06:33:25 -0400 Received: by mail-pf0-f169.google.com with SMTP id o126so5589121pfb.3 for ; Wed, 05 Apr 2017 03:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wPWiBRR2YfGVDa/mBMprL/d2J77eMvXTr5UMN/e2Iro=; b=TmmbxGzcrsJoYWmRPvJk6BSAqRlNMPllF3K3mwxtDK2HtRqw/VOmHqRHj7sIhu/QDU XqlDTYIbSj0D8AUtjX5GTLQak5aqcRndPGY7802KqSeRrMHdbGl/v0p4meR8MO489Pr6 a7aqx8O5CpTapoc+NPrFA67XgOUu9JHRLuiVw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wPWiBRR2YfGVDa/mBMprL/d2J77eMvXTr5UMN/e2Iro=; b=IvV9jeV/r2IyoYadoG/u8/u2l9NF6fUEb/WFIVh/XfZL7RKnMtNph0q1CKo992Sr5K fCzRVcbt88B8FiJTjEZ6pJsyv6iv5/3NBFEFszDlFA9z33/x6ArUIBhehmdSEuVV+cAL WovVj4G3B4uvl+rFkVv1rMA2t0VG2Nz2mlcT2LdmbyUw/BGPfTzan7SeaEEATXWtZeos 6iaT/ROUuzdjm9anSIHz0y5YxpbrHU1nPWyCZx8IUL3GAbHJM1LCmiF+X2QKldJKDP6g SWLv3MbRZNWQJB316e5CKeyvwgq9dF9xFpBRzjWC7iAus09thY0XCNV40RzUKAfaKS8y DgQg== X-Gm-Message-State: AFeK/H3sXaL3NUfE9q5NujaHfUHn2a8/PtVfrz0KamIBuxv5CPg47Jb0+BKS+Z1yWm0XYCu8 X-Received: by 10.84.224.198 with SMTP id k6mr34713026pln.15.1491388393080; Wed, 05 Apr 2017 03:33:13 -0700 (PDT) Received: from localhost.localdomain ([106.51.240.246]) by smtp.gmail.com with ESMTPSA id a62sm36732075pgc.60.2017.04.05.03.33.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 03:33:12 -0700 (PDT) From: Amit Pundir To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, Tobias Wolf , Sergei Shtylyov , linux-mips@linux-mips.org, Ralf Baechle Subject: [PATCH v2 for-4.9 21/32] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Date: Wed, 5 Apr 2017 16:02:13 +0530 Message-Id: <1491388344-13521-22-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491388344-13521-1-git-send-email-amit.pundir@linaro.org> References: <1491388344-13521-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tobias Wolf An empty __dtb_start to __dtb_end section might result in initial_boot_params being null for arch/mips/ralink. This showed that the boot process hangs indefinitely in of_scan_flat_dt(). Signed-off-by: Tobias Wolf Cc: Sergei Shtylyov Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14605/ Signed-off-by: Ralf Baechle (cherry picked from commit 3ec754410cb3e931a6c4920b1a150f21a94a2bf4) Signed-off-by: Amit Pundir --- drivers/of/fdt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index c89d5d2..6c07f2c 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -738,9 +738,12 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node, const char *pathp; int offset, rc = 0, depth = -1; - for (offset = fdt_next_node(blob, -1, &depth); - offset >= 0 && depth >= 0 && !rc; - offset = fdt_next_node(blob, offset, &depth)) { + if (!blob) + return 0; + + for (offset = fdt_next_node(blob, -1, &depth); + offset >= 0 && depth >= 0 && !rc; + offset = fdt_next_node(blob, offset, &depth)) { pathp = fdt_get_name(blob, offset, NULL); if (*pathp == '/')