[PATCH] nvmem: fix possible integer overflow in nintendo_otp_reg_read()

From: Hangyu Hua
Date: Fri Jul 08 2022 - 02:54:06 EST


bytes of type size_t is passed to words of type int in
nintendo_otp_reg_read. This can lead to integer overflow.

Signed-off-by: Hangyu Hua <hbh25y@xxxxxxxxx>
---
drivers/nvmem/nintendo-otp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/nintendo-otp.c b/drivers/nvmem/nintendo-otp.c
index 33961b17f9f1..eb614c31a6b4 100644
--- a/drivers/nvmem/nintendo-otp.c
+++ b/drivers/nvmem/nintendo-otp.c
@@ -50,7 +50,7 @@ static int nintendo_otp_reg_read(void *context,
{
struct nintendo_otp_priv *priv = context;
u32 *val = _val;
- int words = bytes / WORD_SIZE;
+ size_t words = bytes / WORD_SIZE;
u32 bank, addr;

while (words--) {
--
2.25.1