Skip to contentSkip to conversation

nvmem: fix possible integer overflow in nintendo_otp_reg_read()

PATCH New Hangyu Hua 1 participant 1 message Jul 8, 2022 NVMEM framework

lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH 1/1 nvmem: fix possible integer overflow in nintendo_otp_reg_read()

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

---
 drivers/nvmem/nintendo-otp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/nintendo-otp.c +1 -1
index 33961b17f9f1..eb614c31a6b4 100644
@@ -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--) {
Signature · 1 line
2.25.1