From patchwork Fri Mar 3 02:37:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 94817 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp41480qgd; Thu, 2 Mar 2017 19:12:27 -0800 (PST) X-Received: by 10.98.184.1 with SMTP id p1mr706945pfe.127.1488510747546; Thu, 02 Mar 2017 19:12:27 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6si2702308plj.176.2017.03.02.19.12.27; Thu, 02 Mar 2017 19:12:27 -0800 (PST) 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; dkim=pass header.i=@linaro.org; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751618AbdCCDMQ (ORCPT + 25 others); Thu, 2 Mar 2017 22:12:16 -0500 Received: from mail-pf0-f175.google.com ([209.85.192.175]:35649 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751262AbdCCDMN (ORCPT ); Thu, 2 Mar 2017 22:12:13 -0500 Received: by mail-pf0-f175.google.com with SMTP id j5so28556591pfb.2 for ; Thu, 02 Mar 2017 19:11:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=hicD09EpGwAcemQqZQ8M9mojTmMOYj28Q4j/zxeBI+o=; b=avUYxjNU4ux7Qd+DHBy3qEpJaALUvsB+Z0QbwxMdyIywWT6xvCIQhOqiq6t9yfBUit DOfpBZgdiztEo3KrgRI43nO1AUIxZIFYqWRY4qorBFzDlWzrOOzUChDw7v6X57DVufm5 jaQHYxaBc5hkgf00oKDRNRbFhHaux0PRdK+wQ= 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; bh=hicD09EpGwAcemQqZQ8M9mojTmMOYj28Q4j/zxeBI+o=; b=Dbh8RLzdff9/LDdbfzoghQ7M+R+9KqDb/BJa5lVb1Q3K0rDXo7rHMlikH3e3JlD8Ut whScEYeC8nZHAX5MD6UX42WRrGgXrSQ16C3Qtv66qO+3X1TVodtlaFh9rBNLp3TJPQTa oOinpw/eEritMvEQX29c/nk6oGgpGBkG/taxtUVyXbvgDr+F/gC75P/s7orWsq+MYbLG E//iCwpePTiyHsMGmQ/wFuClFiS86ACN88sJRlFavcMVgAGJDeV6hMxh8UhUierWVoWe KBDqhLSOKA1ygdL+2u2ulXU1ITyD4w/LmGwMAYBkOQm1cSYBxAbq1xF5Lfk+MpkNkDFm c3Ng== X-Gm-Message-State: AMke39nfmvCgs3+CNK4QuKZiowegPCTHTgS1gd5E9WboVZqwkdwtAfU2t/r5kJ3N0wsG+3h9 X-Received: by 10.84.210.167 with SMTP id a36mr748699pli.40.1488508542896; Thu, 02 Mar 2017 18:35:42 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id a77sm19533999pfj.1.2017.03.02.18.35.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Mar 2017 18:35:42 -0800 (PST) From: AKASHI Takahiro To: akpm@linux-foundation.org Cc: paul.burton@imgtec.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, AKASHI Takahiro Subject: [PATCH] memblock: fix memblock_next_valid_pfn() Date: Fri, 3 Mar 2017 11:37:45 +0900 Message-Id: <20170303023745.9104-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Obviously, we should not access memblock.memory.regions[right] if 'right' is outside of [0..memblock.memory.cnt>. Fixes: b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") Signed-off-by: AKASHI Takahiro --- mm/memblock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.11.1 diff --git a/mm/memblock.c b/mm/memblock.c index b64b47803e52..696f06d17c4e 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1118,7 +1118,10 @@ unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, } } while (left < right); - return min(PHYS_PFN(type->regions[right].base), max_pfn); + if (right == type->cnt) + return max_pfn; + else + return min(PHYS_PFN(type->regions[right].base), max_pfn); } /**