Skip to content

Commit b3495ce

Browse files
deepa-hubdtor
authored andcommitted
Input: uinput - use monotonic times for timestamps
struct timeval which is part of struct input_event to maintain the event times is not y2038 safe. Real time timestamps are also not ideal for input_event as this time can go backwards as noted in the patch a80b83b by John Stultz. The patch switches the timestamps to use monotonic time from realtime time. This is assuming no one is using absolute times from these timestamps. The structure to maintain input events will be changed in a different patch. Signed-off-by: Deepa Dinamani <[email protected]> Acked-by: Peter Hutterer <[email protected]> Patchwork-Id: 10118255 Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent d09ac61 commit b3495ce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/input/misc/uinput.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ static int uinput_dev_event(struct input_dev *dev,
8484
unsigned int type, unsigned int code, int value)
8585
{
8686
struct uinput_device *udev = input_get_drvdata(dev);
87+
struct timespec64 ts;
8788

8889
udev->buff[udev->head].type = type;
8990
udev->buff[udev->head].code = code;
9091
udev->buff[udev->head].value = value;
91-
do_gettimeofday(&udev->buff[udev->head].time);
92+
ktime_get_ts64(&ts);
93+
udev->buff[udev->head].time.tv_sec = ts.tv_sec;
94+
udev->buff[udev->head].time.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
9295
udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE;
9396

9497
wake_up_interruptible(&udev->waitq);

0 commit comments

Comments
 (0)