Commit 4c54228a authored by Dan Carpenter's avatar Dan Carpenter Committed by Krzysztof Kozlowski

memory: omap-gpmc: Fix a couple off by ones

These comparisons should be >= instead of > to prevent reading one
element beyond the end of the gpmc_cs[] array.

Fixes: cdd6928c ("ARM: OMAP2+: Add device-tree support for NOR flash")
Fixes: f37e4580 ("ARM: OMAP2: Dynamic allocator for GPMC memory space")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarRoger Quadros <rogerq@ti.com>
Link: https://lore.kernel.org/r/20200825104707.GB278587@mwandaSigned-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
parent f42ae4bb
......@@ -990,7 +990,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;
}
......@@ -1025,7 +1025,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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment