Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp172019pxx; Wed, 28 Oct 2020 01:32:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl8Qx3kDr/Z9O0pJrgGR+lOft8g8gvH9XJkqTS4/WN6vRTs96VOhbDe/TEebh9NBOX5FtV X-Received: by 2002:a50:eb0a:: with SMTP id y10mr6901589edp.342.1603873925044; Wed, 28 Oct 2020 01:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873925; cv=none; d=google.com; s=arc-20160816; b=wdD9+EQolJbctMmj5eS3WJgxI0CpySPz9BSjAVIrrYakXuPmED4B3xVBZAq3M8DTH6 igcPzzp02+gryIrQqJmZ4numnB18G2nqUPG/1r+kRGIP24ACER9GpMzdktY6Gu2qq2AG l21/RzKLFrUGZNCyCKMfGU2lsCjENjbYP4S2qQlOs/2Gms1NoCEZa4dQuCRhaz6vTsGY 2+dZKTNPiuL0usjh2M/AI9hKOvPs/VdAdnPaobXq3lRcbEje/IoZvBpHGITaO8LwnCHX U39UDfmB1TJUw/BN+xIwwMCJBcOXMiW8arfkQc4XABldsrpqmrlzKWznpYEXtSdjiPfp xkCw== 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=8ZnM7TGMCPWbMZxZo2tzYknKHrU8SPJgt1ti2wT59d0=; b=LZX0TQPruWAFlDX1wPT5jFFIkmSlahfnVu9ldiuQJNKOjCzG3HdOO8p2Glymeuqok8 NSxVtlkMYe+cPGhquxll88Kr6To+BdD/50z+HJ55m2L8FWOSsQ6dbFakQsceL+UrAWs3 O4fd4OqOoYpO8GtqoW6uD+I0d1aj7eOd7gRAQqa+LLXV+mkrnC/RozE8Vag7aJYxO7qo 1sB+Ii3kdyFQNohX/9N3hRcTi81xxvaguIC0Elfji5AtZzzNtjqFDMMFc5m9v3Qsflsu jpkR3UGhfWzTaL5gRXKMxkVrXfvKXgxOmVMsPXn6l6RUqGnmb4T2Z+9Xov0wdU/ydeT0 Utdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=knmEt21Y; 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 z8si2802677eju.267.2020.10.28.01.31.43; Wed, 28 Oct 2020 01:32:05 -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=knmEt21Y; 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 S2505404AbgJ0OFk (ORCPT + 99 others); Tue, 27 Oct 2020 10:05:40 -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 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 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; } -- 2.25.1