Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp163974pxx; Wed, 28 Oct 2020 01:15:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQp7oidCsKBX8z1v1c56ti7rS7iH4jpf/iErqI7NKg89COvpMy4ExOIIwu6dS2ErnsXZ/L X-Received: by 2002:a50:aa84:: with SMTP id q4mr6594498edc.331.1603872929343; Wed, 28 Oct 2020 01:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603872929; cv=none; d=google.com; s=arc-20160816; b=rUD6Z77oTT6imxxWkPOr8TSBW2IQDH/1oX9dxDSHl3MpcJ3t1CHiXHFrIbEmjosO1U xerPZeM5Iicd/CfBnxRMKiKKS0aXrz0HGqJSJhJtzvOew06ZipXu/YgBVnI1SeMNESq4 Zk/DufsS4/Gsa1a7B0FgMPOguQz7PJurK1NI8umaYgktxKZIgGZHF36umRMUvOIVtMqF Bo75lk5sbFe+a5H8x8cMmQkUKHvj364M6l0gmX7nzVRm1dESTGMSOyZG3HIPSIAS6/CT U+5rmRKm6PEZQa/vTU/SRy4IMxLevV38eyGKlR6xkNy6v7HCraUyJUmmte6Pbr9Vsfim ZBfA== 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=SUy+ACuz371F8v52Oc9NDR8Yc9DgH9yn3TYLgNR8H6o=; b=sV3zfFSKFcvuUxaRW5pULLYuyy5WDgDzi3u9XVzvKS9lkZ5Nra5amFnbhdH7GpIFFc fnsOjhWVm6I1VeTYJVNyxVJaN2y/rnBLuHMXZ/q1+eEAvhkP3Q6MfZW+S3PyrS4UPDa3 sFMHCTJLGeN5JoBXNlkHFBKakMgNxZeZKsLAW89JiBP4FMvkBYQGX9hDz6GyzKy9lXw4 /0I+5gJaybaczI8J/4h1fJy4HajybcRBwLekFbj0Lh+ef/1KVuHa0v0hU1Kd4k4p8801 IUbWOE6RxZtNPOLfFatLVyba2K5fjLGM5hDq42rt5DWGic4l4CgNZPy3PhmRRunHtbv2 +oEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DyMtCPMO; 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 t1si2868715ejb.712.2020.10.28.01.15.07; Wed, 28 Oct 2020 01:15:29 -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=DyMtCPMO; 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 S1753580AbgJ0OAt (ORCPT + 99 others); Tue, 27 Oct 2020 10:00:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:47234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752386AbgJ0N7m (ORCPT ); Tue, 27 Oct 2020 09:59:42 -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 81D61218AC; Tue, 27 Oct 2020 13:59:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807182; bh=awAwHl2l1lqoAKnhM1zlJmktAQRGZGMRhrpWOz2/8bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DyMtCPMOzFKOGqg5EZWr5EbVUuuGUCmf2eN0jLub7ZsycYP2Una0rZQO/TOiPAuTU GW9NMrhvCHz4ydeu/Cr6cRxKrT4RXpHDJ95bDrVTP2qFV10pTrThfn8vJeNO8jZQrf bOrikwLdUoMrmjyXjJPRTxGeZlTSqVFEbbEIPyFk= 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.4 073/112] memory: omap-gpmc: Fix a couple off by ones Date: Tue, 27 Oct 2020 14:49:43 +0100 Message-Id: <20201027134904.005456129@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 49691a8c74ee9..af187c91fc33b 100644 --- a/drivers/memory/omap-gpmc.c +++ b/drivers/memory/omap-gpmc.c @@ -928,7 +928,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; } @@ -963,7 +963,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