From patchwork Mon Jun 26 08:01:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 106310 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp103110qge; Mon, 26 Jun 2017 01:01:41 -0700 (PDT) X-Received: by 10.84.132.104 with SMTP id 95mr22596844ple.228.1498464101749; Mon, 26 Jun 2017 01:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498464101; cv=none; d=google.com; s=arc-20160816; b=fTLcXr1ac/uX/qNkt1xkLgaMHMBquzsAa+IL8h3fgusThUIfsBeCTEzx9ZkFP1wgWZ mXCVaczDIjswiwmhC9Ltys12cV1flhIXv753gnVm9/UDVM+n0pyYgnTYU94cJPBauIXj H4ZzV6SDAfWvp2/oJ4F+KF8RHp1FmabXp2ycQ7NWBWvCEy5SkNOZhcCeuHfM0fnot87e VGyynz97to0wzJIcXcmXxy94xCAIYsuGeg7brKPD5JcR/lVggcvdMdgsHO1gvFlbnxrW EhNQW//s9QgpygrdSmcQ5jkg3cE7eX1WwTzIaXjDd3ol1QsYObwDfNvvRZyARWvcmyp6 BF8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ncm/bd4hE5HMt4rr46HJNlF/RefUPQ/Rf7IHTB1BPls=; b=LH8nxdU7LvKJR/2tPC9QDLkM8SVPQTM8EmhIya83Yte0989yzAILsl861ggi5pxH2x 9keVGDehSzZLFblt5ciawShJ7pwxx60XFVkbN4YIo/fhjMEWdaten1nCHFwHVhOaZ0Ig aHH1AeqwcqlSDDUIBmo+jLUokoWR7rV6rLWAjtPVo3BxnRltQ5hxE4ku488j3W0MAy7j xr1arNzYC9UB9LTVmoNguPeNlG/2HdWiP6fhahv59D4SZcKWFwI3KPOQb3zheGEfKj57 BLbYF2mFCouQAvqtvuDOxLjXcs7be9btrf/vOsZ8BLhzdWNwR1fHa3oOolrIM/xZzS3r sFIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=GyNaXOdV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 102si8959663pld.125.2017.06.26.01.01.41; Mon, 26 Jun 2017 01:01:41 -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 header.b=GyNaXOdV; 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 S1751383AbdFZIBl (ORCPT + 6 others); Mon, 26 Jun 2017 04:01:41 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:33699 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751353AbdFZIBk (ORCPT ); Mon, 26 Jun 2017 04:01:40 -0400 Received: by mail-pf0-f173.google.com with SMTP id e7so51445600pfk.0 for ; Mon, 26 Jun 2017 01:01:40 -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=ncm/bd4hE5HMt4rr46HJNlF/RefUPQ/Rf7IHTB1BPls=; b=GyNaXOdVRQR1a/yWN+Mjx8VC02KdOoK7c5quH/0Co56iBdS3WK8A2UqLL15t4JuyIJ cWLRdIXBacBReLDYbs0khP6wsTGc2Fy+2bbUoweycAM5/eR+WhTWndpSkrzKwaFU3kVi u1OX+GvXsEX5iDn2pfB2Hf4kD/4ZQ2l6SCSiM= 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=ncm/bd4hE5HMt4rr46HJNlF/RefUPQ/Rf7IHTB1BPls=; b=StNSxT+7mcEu9r2rPXR0pjTyN3vrPRFe0X8soeZwJauS6XueyXV/DNejHrSs/REsMC RB9js2+j6G6BKjZLcCp0A1RWQek6GzqMv0QXwwA+VANiCXgIKpT2FJtNHJU+HtjVzmvK MGh5Aj3OUg+zOF9twJz25KD+sSfyUdnA5LH0E7wyR/beu/Z29OwUycXMRQf5WZics45W zYNcIfVkw5loNfdY4yh4eFKtGiTxnStMUipX/7oUhu703cLfY4w1YfVfOb4c6QEeZi6a vyZrc/95MS4Q/774yT6pAnAaMt3HLAWlQltAKE7iIoijtTDAfxW/ttN3GoA0Ey4bWtI+ W73w== X-Gm-Message-State: AKS2vOxYWwo3BTQmSVCyXn4YLu3mC+XjAzEe/RMMpUTFEmAYTxZBlO18 7tY8lH+pKmN8MUuxJZ5MPw== X-Received: by 10.98.28.71 with SMTP id c68mr20271040pfc.116.1498464099665; Mon, 26 Jun 2017 01:01:39 -0700 (PDT) Received: from localhost.localdomain ([106.51.139.251]) by smtp.gmail.com with ESMTPSA id 67sm23673640pfa.83.2017.06.26.01.01.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jun 2017 01:01:38 -0700 (PDT) From: Amit Pundir To: Greg KH Cc: Stable , Tobias Wolf , Sergei Shtylyov , linux-mips@linux-mips.org, Ralf Baechle Subject: [PATCH for-4.9 1/7] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Date: Mon, 26 Jun 2017 13:31:25 +0530 Message-Id: <1498464091-26753-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498464091-26753-1-git-send-email-amit.pundir@linaro.org> References: <1498464091-26753-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 commit 3ec754410cb3e931a6c4920b1a150f21a94a2bf4 upstream. 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 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 6a43fd3d0576..502f5547a1f2 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -741,9 +741,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 == '/')