summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Goodbody <andrew.goodbody@linaro.org>2025-07-23 15:13:48 +0100
committerEugen Hristev <eugen.hristev@linaro.org>2025-08-13 12:59:36 +0300
commit29ea990a1c4a2455f432d5e71b217e93b406fc12 (patch)
tree009eedbb5871a0d4ad71bf9030ffc5e698217090
parent709b5be0a48d4e5bb95ef0b107c56045a8fe67c6 (diff)
clk: at91: Fix testing of unsigned variable to be negative
The variable 'index' is declared as unsigned but used to receive the return value of a function returning 'int'. This value is then tested for being less than zero to detect an error condition but as index is unsigned this can never be true. Change the variable 'index' to be an int so that the error condition can be detected. This issue was found by Smatch. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
-rw-r--r--drivers/clk/at91/clk-main.c3
-rw-r--r--drivers/clk/at91/clk-master.c4
2 files changed, 4 insertions, 3 deletions
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index a5186f885f0..0542b066788 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -315,7 +315,8 @@ static int clk_sam9x5_main_set_parent(struct clk *clk, struct clk *parent)
{
struct clk_main *main = to_clk_main(clk);
void __iomem *reg = main->reg;
- unsigned int tmp, index;
+ unsigned int tmp;
+ int index;
index = at91_clk_mux_val_to_index(main->clk_mux_table,
main->num_parents, AT91_CLK_ID_TO_DID(parent->id));
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index cdc5271fa83..530205b8c6b 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -335,8 +335,8 @@ struct clk *at91_clk_sama7g5_register_master(void __iomem *base,
{
struct clk_master *master;
struct clk *clk;
- u32 val, index;
- int ret;
+ u32 val;
+ int ret, index;
if (!base || !name || !num_parents || !parent_names ||
!mux_table || !clk_mux_table || id > MASTER_MAX_ID)