From patchwork Tue Oct 27 13:49:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 290134 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 13AEFC6369E for ; Tue, 27 Oct 2020 14:11:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D25C92072D for ; Tue, 27 Oct 2020 14:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807872; bh=jHxDksZgHmwRlabS+A2MyEqNeUmeHS23bUAZhvGP/fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=01ayj3SVhG1E1a9Q92RhKqkyU08dCwQz5nIhTUkEAkjmDsw8wMhnCKq5KzImaOH9m 4b4EjhLIiBsJea7iv1COpWXAeseu08CbJEAtddoJeDNxz4gUwMY3P96JciqqdnwgYR 8oDm+5kVigjK/N4BPJlQKNylT/gLZ/dM1awEPocM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1746289AbgJ0OFe (ORCPT ); Tue, 27 Oct 2020 10:05:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:53870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754450AbgJ0OFe (ORCPT ); Tue, 27 Oct 2020 10:05:34 -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 0EF4A2222C; Tue, 27 Oct 2020 14:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807533; bh=jHxDksZgHmwRlabS+A2MyEqNeUmeHS23bUAZhvGP/fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=knmEt21Y9bxeLBGbjLDU5kVVX9BCD1AIIOagr6fxsQv6Z3KMxr3KwTaxJuzBbnQJF 9Oztm2YttJ77uFZ8Arg69Fz0RT+cpWuGDGLyjYl2NuUBkpUX+L0Hdq7ZQtamOl9sQr qfbcCwqYsQQIaqZ9IpDU8yKLJCyVylUFkfLiQcUQ= 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.9 087/139] memory: omap-gpmc: Fix a couple off by ones Date: Tue, 27 Oct 2020 14:49:41 +0100 Message-Id: <20201027134906.262078089@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134902.130312227@linuxfoundation.org> References: <20201027134902.130312227@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 bf0fe0137dfed..a9d47c06f80f3 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; }