linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: omap-gpmc: fix coverity issue "Control flow issues"
@ 2022-11-09 10:24 B. Niedermayr
  2022-11-09 12:24 ` Roger Quadros
  2022-11-10  9:14 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: B. Niedermayr @ 2022-11-09 10:24 UTC (permalink / raw)
  To: linux-next
  Cc: linux-kernel, linux-omap, linux-hardening, keescook,
	krzysztof.kozlowski, rogerq, tony, gustavo

From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

Assign a big positive integer instead of an negative integer to an
u32 variable. Also remove the check for ">= 0" which doesn't make sense
for unsigned integers.

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1527139 ("Control flow issues")
Fixes: 89aed3cd5cb9 ("memory: omap-gpmc: wait pin additions")
Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
 drivers/memory/omap-gpmc.c              | 2 +-
 include/linux/platform_data/gpmc-omap.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index e427572712e2..57d9f91fe89b 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -1045,7 +1045,7 @@ EXPORT_SYMBOL(gpmc_cs_free);
 
 static bool gpmc_is_valid_waitpin(u32 waitpin)
 {
-	return waitpin >= 0 && waitpin < gpmc_nr_waitpins;
+	return waitpin < gpmc_nr_waitpins;
 }
 
 static int gpmc_alloc_waitpin(struct gpmc_device *gpmc,
diff --git a/include/linux/platform_data/gpmc-omap.h b/include/linux/platform_data/gpmc-omap.h
index 296b080c5c67..dcca6c5e23bb 100644
--- a/include/linux/platform_data/gpmc-omap.h
+++ b/include/linux/platform_data/gpmc-omap.h
@@ -137,11 +137,11 @@ struct gpmc_device_timings {
 #define GPMC_MUX_AD			2	/* Addr-Data multiplex */
 
 /* Wait pin polarity values */
-#define GPMC_WAITPINPOLARITY_INVALID -1
+#define GPMC_WAITPINPOLARITY_INVALID UINT_MAX
 #define GPMC_WAITPINPOLARITY_ACTIVE_LOW 0
 #define GPMC_WAITPINPOLARITY_ACTIVE_HIGH 1
 
-#define GPMC_WAITPIN_INVALID -1
+#define GPMC_WAITPIN_INVALID UINT_MAX
 
 struct gpmc_settings {
 	bool burst_wrap;	/* enables wrap bursting */
-- 
2.25.1


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

* Re: [PATCH] memory: omap-gpmc: fix coverity issue "Control flow issues"
  2022-11-09 10:24 [PATCH] memory: omap-gpmc: fix coverity issue "Control flow issues" B. Niedermayr
@ 2022-11-09 12:24 ` Roger Quadros
  2022-11-10  9:14 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Roger Quadros @ 2022-11-09 12:24 UTC (permalink / raw)
  To: B. Niedermayr, linux-next
  Cc: linux-kernel, linux-omap, linux-hardening, keescook,
	krzysztof.kozlowski, tony, gustavo



On 09/11/2022 12:24, B. Niedermayr wrote:
> From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> 
> Assign a big positive integer instead of an negative integer to an
> u32 variable. Also remove the check for ">= 0" which doesn't make sense
> for unsigned integers.
> 
> Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
> Addresses-Coverity-ID: 1527139 ("Control flow issues")
> Fixes: 89aed3cd5cb9 ("memory: omap-gpmc: wait pin additions")
> Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

Reviewed-by: Roger Quadros <rogerq@kernel.org>

> ---
>  drivers/memory/omap-gpmc.c              | 2 +-
>  include/linux/platform_data/gpmc-omap.h | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
> index e427572712e2..57d9f91fe89b 100644
> --- a/drivers/memory/omap-gpmc.c
> +++ b/drivers/memory/omap-gpmc.c
> @@ -1045,7 +1045,7 @@ EXPORT_SYMBOL(gpmc_cs_free);
>  
>  static bool gpmc_is_valid_waitpin(u32 waitpin)
>  {
> -	return waitpin >= 0 && waitpin < gpmc_nr_waitpins;
> +	return waitpin < gpmc_nr_waitpins;
>  }
>  
>  static int gpmc_alloc_waitpin(struct gpmc_device *gpmc,
> diff --git a/include/linux/platform_data/gpmc-omap.h b/include/linux/platform_data/gpmc-omap.h
> index 296b080c5c67..dcca6c5e23bb 100644
> --- a/include/linux/platform_data/gpmc-omap.h
> +++ b/include/linux/platform_data/gpmc-omap.h
> @@ -137,11 +137,11 @@ struct gpmc_device_timings {
>  #define GPMC_MUX_AD			2	/* Addr-Data multiplex */
>  
>  /* Wait pin polarity values */
> -#define GPMC_WAITPINPOLARITY_INVALID -1
> +#define GPMC_WAITPINPOLARITY_INVALID UINT_MAX
>  #define GPMC_WAITPINPOLARITY_ACTIVE_LOW 0
>  #define GPMC_WAITPINPOLARITY_ACTIVE_HIGH 1
>  
> -#define GPMC_WAITPIN_INVALID -1
> +#define GPMC_WAITPIN_INVALID UINT_MAX
>  
>  struct gpmc_settings {
>  	bool burst_wrap;	/* enables wrap bursting */

--
cheers,
-roger

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

* Re: [PATCH] memory: omap-gpmc: fix coverity issue "Control flow issues"
  2022-11-09 10:24 [PATCH] memory: omap-gpmc: fix coverity issue "Control flow issues" B. Niedermayr
  2022-11-09 12:24 ` Roger Quadros
@ 2022-11-10  9:14 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2022-11-10  9:14 UTC (permalink / raw)
  To: B. Niedermayr, linux-next
  Cc: Krzysztof Kozlowski, linux-hardening, gustavo, keescook,
	linux-kernel, rogerq, tony, linux-omap

On Wed, 9 Nov 2022 11:24:54 +0100, B. Niedermayr wrote:
> From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> 
> Assign a big positive integer instead of an negative integer to an
> u32 variable. Also remove the check for ">= 0" which doesn't make sense
> for unsigned integers.
> 
> 
> [...]

Applied, thanks!

[1/1] memory: omap-gpmc: fix coverity issue "Control flow issues"
      https://git.kernel.org/krzk/linux-mem-ctrl/c/10913c3c59ce04562230eee4a9d1b0d4e2808842

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

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

end of thread, other threads:[~2022-11-10  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 10:24 [PATCH] memory: omap-gpmc: fix coverity issue "Control flow issues" B. Niedermayr
2022-11-09 12:24 ` Roger Quadros
2022-11-10  9:14 ` 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).