Only read the requested number of events from the kernel rather than
reading up to 16 and quietly discarding any surplus.
The previous behavour is particularly bad for reading single events as
userspace must read the events as quickly as they arrive, effectively
negating the presence of the kernel event kfifo.
Fixes: 44921ecc9a00 ("core: provide functions for reading multiple line events at once")
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
memset(evdata, 0, sizeof(evdata));
- rd = read(fd, evdata, sizeof(evdata));
+ if (num_events > 16)
+ num_events = 16;
+
+ rd = read(fd, evdata, num_events * sizeof(*evdata));
if (rd < 0) {
return -1;
} else if ((unsigned int)rd < sizeof(*evdata)) {