Skip to contentSkip to conversation

Pinctrl: Add in zero check

PATCH In review Will Shiu 3 participants 4 messages Aug 16, 2022 – Aug 25, 2022

Subsystems (2)
lore
Share & tools
lore

Will Shiu

author
#0 lore raw

PATCH 1/1 Pinctrl: Add in zero check

add in check of buffer offset to avoid the exception when input 0 size.

---
 drivers/pinctrl/pinmux.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pinctrl/pinmux.c +3 -0
index f94d43b082d9..646dff591b21 100644
@@ -689,6 +689,9 @@ static ssize_t pinmux_select(struct file *file, const char __user *user_buf,
 	if (len > PINMUX_SELECT_MAX)
 		return -ENOMEM;
 
+	if (len <= 0)
+		return -EINVAL;
+
 	buf = kzalloc(PINMUX_SELECT_MAX, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
Signature · 1 line
2.18.0
#2 lore raw
Quoted 7 lines · Linus Walleij
Quoted 3 lines · Will Shiu

add in check of buffer offset to avoid the exception when input 0 size.

Looks good to me, patch applied!

Sorry, but it seems the author didn't pay much attention and didn't really work on it. What does the < 0 comparison mean here?

I would ask if there is _real_ issue with the code? What is the use case and why is this check needed?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Linus Walleij
Quoted 3 lines · Will Shiu

add in check of buffer offset to avoid the exception when input 0 size.

Quoted 7 lines
Quoted 1 line

Looks good to me, patch applied!

Sorry, but it seems the author didn't pay much attention and didn't really work on it. What does the < 0 comparison mean here?

I would ask if there is _real_ issue with the code? What is the use case and why is this check needed?

Dropped this until Andy's question is answered.

Yours,
Linus Walleij