gpio: virtuser: Fix uninitialized data bug in gpio_virtuser_direction_do_write()
Subsystems (2)
PATCH 1/1 gpio: virtuser: Fix uninitialized data bug in gpio_virtuser_direction_do_write()
If *ppos is non-zero then simple_write_to_buffer() won't initialize the start of the buffer. Really, non-zero values for *ppos aren't going to work at all. Check for that return -EINVAL at the start of the function.
Fixes 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GPIO API")
Signed-off-by Dan Carpenter <[email protected]>
---
drivers/gpio/gpio-virtuser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-virtuser.c +2 -2
@@ -397,7 +397,7 @@ static ssize_t gpio_virtuser_direction_do_write(struct file *file,char buf[32 ], *trimmed;int ret, dir, val =0 ; -if (count >=sizeof (buf)) +if (*ppos !=0 || count >=sizeof (buf))return -EINVAL ; ret =simple_write_to_buffer (buf,sizeof (buf) -1 , ppos, user_buf, count);
@@ -622,7 +622,7 @@ static ssize_t gpio_virtuser_consumer_write(struct file *file,char buf[GPIO_VIRTUSER_NAME_BUF_LEN +2 ];int ret; -if (count >=sizeof (buf)) +if (*ppos !=0 || count >=sizeof (buf))return -EINVAL ; ret = simple_write_to_buffer(buf, GPIO_VIRTUSER_NAME_BUF_LEN, ppos,
Signature · 1 line
2.53.0
Quoted 5 lines · Dan Carpenter
If *ppos is non-zero then
simple_write_to_buffer()won't initialize the start of the buffer. Really, non-zero values for *ppos aren't going to work at all. Check for that return-EINVALat the start of the function.
I tweaked the commit message a bit for clarity, thanks.
[1/1] gpio: virtuser: Fix uninitialized data bug in gpio_virtuser_direction_do_write()
https://git.kernel.org/brgl/c/39785f2b3e9fb8f3375dde1e3e4c94ff953871af
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>