From patchwork Tue Oct 27 13:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 312327 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 E7C01C55178 for ; Tue, 27 Oct 2020 16:29:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8ABC72222C for ; Tue, 27 Oct 2020 16:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603816155; bh=EMkcT2i5uOjrTgGJ4EVBaMOozDKG5DGNbRy6bs4IlK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SuV0Fu8kNMaW9D0hjJ6v07KWmCqRWxkjuaQ/e40CyYr5m8vagZQevC6pZPDYXJD2A 4POHCT7sZ/dfr8N8x6JDKdMFSzmO/vAXb/HTzyDylQbErV6AkpAjrxpfjUGwEGlOSg k/sWdrpWRnjGsJQxtYRl3TfH2xIdNLDg0qyFsVLQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1802728AbgJ0PvG (ORCPT ); Tue, 27 Oct 2020 11:51:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:42952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1802165AbgJ0Ppu (ORCPT ); Tue, 27 Oct 2020 11:45:50 -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 87C1A21D42; Tue, 27 Oct 2020 15:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813550; bh=EMkcT2i5uOjrTgGJ4EVBaMOozDKG5DGNbRy6bs4IlK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OwgGta7lCWrq17RpdJySFcyni+r/bMjdbJlp4+7fO9How4UtNDoFHh479XZbCZmPH x1iq4C+FhhnFm6vFWCcry/1BjHd/dit2wOdzhawxsdg+X9rbvcT0eq9pZ0jy+0MTTQ RIubVHjbJCtUCGmjwl7JDXX8ILaIFmn06ddun5y4= 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 5.9 590/757] memory: omap-gpmc: Fix a couple off by ones Date: Tue, 27 Oct 2020 14:54:00 +0100 Message-Id: <20201027135518.215764206@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@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 ca0097664b125..1e6d6e9434c8b 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -943,7 +943,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; } @@ -978,7 +978,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; }