From patchwork Wed Nov 19 17:18:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 41199 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 09799241C9 for ; Wed, 19 Nov 2014 17:18:39 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id c13sf1011277eek.6 for ; Wed, 19 Nov 2014 09:18:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=Rc34YQoQ+V8s6bnowx8UMQRYpCArnIihZkUzuBqSwRM=; b=Rn4zV/fPqLkC9JycdZG/Ssced4uB6vcfSZyfDrV+C0nFi45sdOjj/qP8jt48IYtNXk Xy5km3AIlZ1uWhIrBbaP9nS5OFuL5GIZWb6lh6VwQaIYGRaL3uTfRn4H7xFdS7bqYjwS sDgDPfbSQcg+EhBfdyGIT47hBUQTK7v1NZlbpqnEtRwkYxouLdv4Lt5GqVLQyCOrOz4O /ETYIdWC9eNTKEV7Tj9FpSkCwU6bwC+GXD6BbxiuqeJqt3PY3Mflws4emkJ2TDfJzkQh KOvbrZ8XUb9sqBeuSyDIZQqQdU5ELOCvppDJuDk9ZGVxuu9cjHLv5ZuaLyJVeP1hpM3n bRGA== X-Gm-Message-State: ALoCoQncTnEtA65tRTzV8ADQsrY/hWTHMpD8yM5yKdLZKHYJbvSlHxEvb0GM1kSvaArdY9VjfhMZ X-Received: by 10.180.182.164 with SMTP id ef4mr1020387wic.0.1416417518274; Wed, 19 Nov 2014 09:18:38 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.4 with SMTP id i4ls1545517laf.59.gmail; Wed, 19 Nov 2014 09:18:38 -0800 (PST) X-Received: by 10.112.151.70 with SMTP id uo6mr42764615lbb.2.1416417518109; Wed, 19 Nov 2014 09:18:38 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ke10si2446467lbc.41.2014.11.19.09.18.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 09:18:38 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id z11so852756lbi.39 for ; Wed, 19 Nov 2014 09:18:38 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr6378553laj.67.1416417517903; Wed, 19 Nov 2014 09:18:37 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp123093lbc; Wed, 19 Nov 2014 09:18:37 -0800 (PST) X-Received: by 10.68.131.3 with SMTP id oi3mr18689912pbb.27.1416417516375; Wed, 19 Nov 2014 09:18:36 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ha5si3678682pbb.93.2014.11.19.09.18.35 for ; Wed, 19 Nov 2014 09:18:36 -0800 (PST) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755113AbaKSRSe (ORCPT + 1 other); Wed, 19 Nov 2014 12:18:34 -0500 Received: from mail-wi0-f176.google.com ([209.85.212.176]:40702 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754998AbaKSRSc (ORCPT ); Wed, 19 Nov 2014 12:18:32 -0500 Received: by mail-wi0-f176.google.com with SMTP id ex7so6124838wid.3 for ; Wed, 19 Nov 2014 09:18:31 -0800 (PST) X-Received: by 10.180.208.8 with SMTP id ma8mr7640180wic.53.1416417511402; Wed, 19 Nov 2014 09:18:31 -0800 (PST) Received: from trevor.secretlab.ca (host86-166-84-117.range86-166.btcentralplus.com. [86.166.84.117]) by mx.google.com with ESMTPSA id s8sm3118390wjx.9.2014.11.19.09.18.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Nov 2014 09:18:30 -0800 (PST) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 2237FC40E90; Wed, 19 Nov 2014 17:18:27 +0000 (GMT) From: Grant Likely To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Kevin Hilman , Grant Likely , Rob Herring , Gaurav Minocha , Subject: [PATCH] of/selftest: Fix off-by-one error in removal path Date: Wed, 19 Nov 2014 17:18:22 +0000 Message-Id: <1416417502-25869-1-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grant.likely@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The removal path for selftest data has an off by one error that causes the code to dereference beyond the end of the nodes[] array on the first pass through. The old code only worked by chance on a lot of platforms, but the bug was recently exposed on aarch64. The fix is simple. Decrement the node count before dereferencing, not after. Reported-by: Kevin Hilman Cc: Rob Herring Cc: Gaurav Minocha Cc: # v3.17+ --- drivers/of/selftest.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c index 11b873c54a77..e6c14dc400e9 100644 --- a/drivers/of/selftest.c +++ b/drivers/of/selftest.c @@ -896,7 +896,7 @@ static void selftest_data_remove(void) return; } - while (last_node_index >= 0) { + while (last_node_index-- > 0) { if (nodes[last_node_index]) { np = of_find_node_by_path(nodes[last_node_index]->full_name); if (strcmp(np->full_name, "/aliases") != 0) { @@ -908,7 +908,6 @@ static void selftest_data_remove(void) } } } - last_node_index--; } }