Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memory: omap-gpmc: fix coverity issue "Control flow issues"

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>
Link: https://lore.kernel.org/r/20221109102454.174320-1-benedikt.niedermayr@siemens.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

authored by

Benedikt Niedermayr and committed by
Krzysztof Kozlowski
8dd7e4af 1f1e46b8

+3 -3
+1 -1
drivers/memory/omap-gpmc.c
··· 1045 1045 1046 1046 static bool gpmc_is_valid_waitpin(u32 waitpin) 1047 1047 { 1048 - return waitpin >= 0 && waitpin < gpmc_nr_waitpins; 1048 + return waitpin < gpmc_nr_waitpins; 1049 1049 } 1050 1050 1051 1051 static int gpmc_alloc_waitpin(struct gpmc_device *gpmc,
+2 -2
include/linux/platform_data/gpmc-omap.h
··· 137 137 #define GPMC_MUX_AD 2 /* Addr-Data multiplex */ 138 138 139 139 /* Wait pin polarity values */ 140 - #define GPMC_WAITPINPOLARITY_INVALID -1 140 + #define GPMC_WAITPINPOLARITY_INVALID UINT_MAX 141 141 #define GPMC_WAITPINPOLARITY_ACTIVE_LOW 0 142 142 #define GPMC_WAITPINPOLARITY_ACTIVE_HIGH 1 143 143 144 - #define GPMC_WAITPIN_INVALID -1 144 + #define GPMC_WAITPIN_INVALID UINT_MAX 145 145 146 146 struct gpmc_settings { 147 147 bool burst_wrap; /* enables wrap bursting */