Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1122069pxx; Tue, 27 Oct 2020 08:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV3TyA1acd4E3ovRHU61mdJSIbmGvN5+qLHSXFAYPV1Dw0iHpFuXUNBpAgxXA9chN3TGd9 X-Received: by 2002:aa7:d394:: with SMTP id x20mr2928655edq.14.1603813518692; Tue, 27 Oct 2020 08:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813518; cv=none; d=google.com; s=arc-20160816; b=JrsYU8kYKza9Xui7EwcLIs31RWGsZL4NgzOyDDHdPt+K5IcH6og0Op/sigo1kUBjnD S+xUdx6cgRUZJ/QXJGEVfbLJP4FEuAjseO9tsmskzqxwf/Et82TDTCjK4TeVxSM6FKPe PQy2a3w3K2xVbj7RtEEO1qXade0qLywVdg86Wh5pEfM1nhZqnnUhh/9tektlsRwOwGP/ P4JAibetD2Suk+yxWQmeSiQeseHq5HBhfzXHULOPAIb/qFi8HHlaVZLDNnyYxPEkcJ54 m3Ox1esSwjYEH102rPZO/LjxaVgtrYmQnFiVrIRoLFydTDbCJO5ilRB+Fiw7KBLjCfDP 2xUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d5hhl/yJGEC0A3V/Q351hLqQQ/E9EYDXd25NhE0kn/w=; b=THGIUf3w0W+/hbPMuyL2/dkP572Leahd6aUka8SxgmrkhSuazpyELiUkI7CIljx0kq CUjHzmkYvSgM63xeuX2HdynjwveHGLSK71Yh1UqaLYZc++qxTI3sZVpmVeIlHwZ9u9s4 CZPACKIjYx1Wq8IUwVQ/vpYSkp3SkcA7ZkEvFKsJy4ARpT89bgT4pppQKK+skdo9RO9D rfNFK2g3lOW0aSxs8qOhGHNZmXLCUF4NNRz1oy396lgHg4hsX9R6d5le1BW9EWO6OSxP gwzYUyJTF0r9xWC10L+iaKhgL3+pMQdxQJahI/vLES8m2J9kEztGMF6XXtIkP7rJiEpw KbXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L0K1fokS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i6si1596670ejs.599.2020.10.27.08.44.56; Tue, 27 Oct 2020 08:45:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L0K1fokS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750438AbgJ0OoD (ORCPT + 99 others); Tue, 27 Oct 2020 10:44:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:41910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762347AbgJ0OmR (ORCPT ); Tue, 27 Oct 2020 10:42:17 -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 3406822264; Tue, 27 Oct 2020 14:42:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809736; bh=smbYIs9dT+l/QoU+EsqfoScVZ3k5VgqRrfkSuCKbtvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L0K1fokSC24aCj23JM76nRGEZk+8VfskmnxPgj58ITjFydFXY9OR7e6a3w8UQmc+7 +w/44UYcT7nrrRJTWJ+e6qrKnxflR1TKghK7p1zh614whwY1ZLQFjKEvM8NFoMro1e zz4HSm6/n3VIixWPm1Ovb8zN5UkMGFyzc19+C72E= 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.4 301/408] memory: omap-gpmc: Fix a couple off by ones Date: Tue, 27 Oct 2020 14:53:59 +0100 Message-Id: <20201027135508.991805699@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 eff26c1b13940..b5055577843a2 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -949,7 +949,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; } @@ -984,7 +984,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; } -- 2.25.1