linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: omap-gpmc: Fix a couple off by ones
@ 2020-08-25 10:47 Dan Carpenter
  2020-08-26 13:05 ` Roger Quadros
  2020-08-26 18:22 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-08-25 10:47 UTC (permalink / raw)
  To: Roger Quadros
  Cc: Tony Lindgren, Krzysztof Kozlowski, Jon Hunter, linux-omap,
	linux-kernel, kernel-janitors

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>
---
 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 cd9e80748591..fd245b82163a 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -989,7 +989,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;
 	}
@@ -1024,7 +1024,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.28.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] memory: omap-gpmc: Fix a couple off by ones
  2020-08-25 10:47 [PATCH] memory: omap-gpmc: Fix a couple off by ones Dan Carpenter
@ 2020-08-26 13:05 ` Roger Quadros
  2020-08-26 18:22 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Roger Quadros @ 2020-08-26 13:05 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tony Lindgren, Krzysztof Kozlowski, linux-omap, linux-kernel,
	kernel-janitors

On 25/08/2020 13:47, Dan Carpenter wrote:
> 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>

> ---
>   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 cd9e80748591..fd245b82163a 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -989,7 +989,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;
>   	}
> @@ -1024,7 +1024,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;
>   	}
> 

cheers,
-roger

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] memory: omap-gpmc: Fix a couple off by ones
  2020-08-25 10:47 [PATCH] memory: omap-gpmc: Fix a couple off by ones Dan Carpenter
  2020-08-26 13:05 ` Roger Quadros
@ 2020-08-26 18:22 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2020-08-26 18:22 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Roger Quadros, Tony Lindgren, Jon Hunter, linux-omap,
	linux-kernel, kernel-janitors

On Tue, Aug 25, 2020 at 01:47:07PM +0300, Dan Carpenter wrote:
> 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>
> ---
>  drivers/memory/omap-gpmc.c | 4 ++--

Thanks, applied.

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-26 18:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 10:47 [PATCH] memory: omap-gpmc: Fix a couple off by ones Dan Carpenter
2020-08-26 13:05 ` Roger Quadros
2020-08-26 18:22 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).