[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200624150704.2729736-7-lee.jones@linaro.org>
Date: Wed, 24 Jun 2020 16:07:00 +0100
From: Lee Jones <lee.jones@...aro.org>
To: lee.jones@...aro.org
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org, Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH 06/10] mfd: ab3100-core: Fix incompatible types in comparison expression warning
Smatch reports:
drivers/mfd/ab3100-core.c:501:20: error: incompatible types in comparison expression (different type sizes):
drivers/mfd/ab3100-core.c:501:20: unsigned int *
drivers/mfd/ab3100-core.c:501:20: unsigned long *
drivers/mfd/ab8500-debugfs.c:1804:20: error: incompatible types in comparison expression (different type sizes):
drivers/mfd/ab8500-debugfs.c:1804:20: unsigned int *
drivers/mfd/ab8500-debugfs.c:1804:20: unsigned long *
Since the second min() argument can be less than 0 a signed
variable is required for assignment. However, the non-sized
type size_t is passed in from the userspace handlers. In order
to firstly compare, then assign the smallest value, we firstly
need to cast them both to the same as the receiving size_t typed
variable.
Cc: <stable@...r.kernel.org>
Cc: Linus Walleij <linus.walleij@...aro.org>
Signed-off-by: Lee Jones <lee.jones@...aro.org>
---
drivers/mfd/ab3100-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 57723f116bb58..ee71ae04b5e63 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -498,7 +498,7 @@ static ssize_t ab3100_get_set_reg(struct file *file,
int i = 0;
/* Get userspace string and assure termination */
- buf_size = min(count, (sizeof(buf)-1));
+ buf_size = min((ssize_t)count, (ssize_t)(sizeof(buf)-1));
if (copy_from_user(buf, user_buf, buf_size))
return -EFAULT;
buf[buf_size] = 0;
--
2.25.1
Powered by blists - more mailing lists