Patch "tools: iio: iio_generic_buffer: Fix read size" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    tools: iio: iio_generic_buffer: Fix read size

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     tools-iio-iio_generic_buffer-fix-read-size.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e0a262bde3d071c82909ebedd0fc9c0b1f8cf75d
Author: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
Date:   Fri Oct 14 10:15:19 2022 +0300

    tools: iio: iio_generic_buffer: Fix read size
    
    [ Upstream commit 7c919b619bcc68158921b1bd968f0e704549bbb6 ]
    
    When noevents is true and small buffer is used the allocated memory for
    holding the data may be smaller than the hard-coded 64 bytes. This can
    cause the iio_generic_buffer to crash.
    
    Following was recorded on beagle bone black with v6.0 kernel and the
    digit fix patch:
    https://lore.kernel.org/all/Y0f+tKCz+ZAIoroQ@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
    using valgrind;
    
    ==339== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
    ==339== Command: /iio_generic_buffer -n kx022-accel -T0 -e -l 10 -a -w 2000000
    ==339== Parent PID: 307
    ==339==
    ==339== Syscall param read(buf) points to unaddressable byte(s)
    ==339==    at 0x496BFA4: read (read.c:26)
    ==339==    by 0x11699: main (iio_generic_buffer.c:724)
    ==339==  Address 0x4ab3518 is 0 bytes after a block of size 160 alloc'd
    ==339==    at 0x4864B70: malloc (vg_replace_malloc.c:381)
    ==339==    by 0x115BB: main (iio_generic_buffer.c:677)
    
    Fix this by always using the same size for reading as was used for
    data storage allocation.
    
    Signed-off-by: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
    Link: https://lore.kernel.org/r/Y0kMh0t5qUXJw3nQ@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 2491c54a5e4f..f8deae4e26a1 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -715,12 +715,12 @@ int main(int argc, char **argv)
 				continue;
 			}
 
-			toread = buf_len;
 		} else {
 			usleep(timedelay);
-			toread = 64;
 		}
 
+		toread = buf_len;
+
 		read_size = read(buf_fd, data, toread * scan_size);
 		if (read_size < 0) {
 			if (errno == EAGAIN) {



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux