From patchwork Tue Oct 27 13:54:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 307012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F211C4363A for ; Tue, 27 Oct 2020 17:50:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0532F24198 for ; Tue, 27 Oct 2020 17:50:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603821057; bh=CghIPK6/yOgakJDpDkZ89AZ71nE2f44qjRddKbYZEEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=gt450IRiIKSxlpGWga/wygB3a5ioHQhOaG+kLjOl8zBua6uz0vPGkuUqevCkAxmJo dTiLpG7oeVogMEhIS8rIR8f2iRf4Ns3u8Z4rLwcjD3e4TiXVxEM1Xyc4f3wOrgrIVr k16bwv5v5RxcKed+Uz75GKVGZzCqgFvKdSc68gmk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1822607AbgJ0Ruw (ORCPT ); Tue, 27 Oct 2020 13:50:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:50478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2901592AbgJ0OZF (ORCPT ); Tue, 27 Oct 2020 10:25:05 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 99C3A2072D; Tue, 27 Oct 2020 14:25:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808705; bh=CghIPK6/yOgakJDpDkZ89AZ71nE2f44qjRddKbYZEEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPU2Z1/WfblnGM7eMcjvKUAX3OiDkwl/AiMuUjQzdlh8Hvzwrkr7O62ql0DLd2ZB9 kPC1/sSXW6eenDrtWGp+UURwo0mhskEETuByZVgPmerBTBqV4y7mZttCqcIqYDUbse 73WjRkO6D+HADYEd85jW9hFeGE5mUH1N3DEx9XG0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Roger Quadros , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 4.19 193/264] memory: omap-gpmc: Fix a couple off by ones Date: Tue, 27 Oct 2020 14:54:11 +0100 Message-Id: <20201027135439.731410712@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135430.632029009@linuxfoundation.org> References: <20201027135430.632029009@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dan Carpenter [ Upstream commit 4c54228ac8fd55044195825873c50a524131fa53 ] These comparisons should be >= instead of > to prevent reading one element beyond the end of the gpmc_cs[] array. Fixes: cdd6928c589a ("ARM: OMAP2+: Add device-tree support for NOR flash") Fixes: f37e4580c409 ("ARM: OMAP2: Dynamic allocator for GPMC memory space") Signed-off-by: Dan Carpenter Acked-by: Roger Quadros Link: https://lore.kernel.org/r/20200825104707.GB278587@mwanda Signed-off-by: Krzysztof Kozlowski Signed-off-by: Sasha Levin --- drivers/memory/omap-gpmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index 1c6a7c16e0c17..f5a89e78b7b2b 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -951,7 +951,7 @@ static int gpmc_cs_remap(int cs, u32 base) int ret; u32 old_base, size; - if (cs > gpmc_cs_num) { + if (cs >= gpmc_cs_num) { pr_err("%s: requested chip-select is disabled\n", __func__); return -ENODEV; } @@ -986,7 +986,7 @@ int gpmc_cs_request(int cs, unsigned long size, unsigned long *base) struct resource *res = &gpmc->mem; int r = -1; - if (cs > gpmc_cs_num) { + if (cs >= gpmc_cs_num) { pr_err("%s: requested chip-select is disabled\n", __func__); return -ENODEV; }