diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2020-08-25 13:47:07 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-29 09:03:07 +0100 |
commit | 4b2c1ec1c92cbd0cbeb4d9c98db1eb110a10e65a (patch) | |
tree | 79bd3ca605132ba998f792493d1769f8dd26bc87 | |
parent | 0062678e8de3c3d6f7e54853760bfb9ca66f5e64 (diff) | |
download | linux-stable-4b2c1ec1c92cbd0cbeb4d9c98db1eb110a10e65a.tar.gz linux-stable-4b2c1ec1c92cbd0cbeb4d9c98db1eb110a10e65a.tar.bz2 linux-stable-4b2c1ec1c92cbd0cbeb4d9c98db1eb110a10e65a.zip |
memory: omap-gpmc: Fix a couple off by ones
[ 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 <dan.carpenter@oracle.com>
Acked-by: Roger Quadros <rogerq@ti.com>
Link: https://lore.kernel.org/r/20200825104707.GB278587@mwanda
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/memory/omap-gpmc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c index 49691a8c74ee..af187c91fc33 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; } |