Skip to content

Commit c884f87

Browse files
arndbgregkh
authored andcommitted
tty: use 64-bit timstamp
The automated VFS conversion to timespec64 has left one caller of the deprecated get_seconds() function in the tty driver, this cleans it up to call ktime_get_real_seconds() instead, fixing the possible overflow. Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fb7f1bf commit c884f87

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

drivers/tty/tty_io.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -814,9 +814,9 @@ void start_tty(struct tty_struct *tty)
814814
}
815815
EXPORT_SYMBOL(start_tty);
816816

817-
static void tty_update_time(struct timespec *time)
817+
static void tty_update_time(struct timespec64 *time)
818818
{
819-
unsigned long sec = get_seconds();
819+
time64_t sec = ktime_get_real_seconds();
820820

821821
/*
822822
* We only care if the two values differ in anything other than the
@@ -867,13 +867,8 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
867867
i = -EIO;
868868
tty_ldisc_deref(ld);
869869

870-
if (i > 0) {
871-
struct timespec ts;
872-
873-
ts = timespec64_to_timespec(inode->i_atime);
874-
tty_update_time(&ts);
875-
inode->i_atime = timespec_to_timespec64(ts);
876-
}
870+
if (i > 0)
871+
tty_update_time(&inode->i_atime);
877872

878873
return i;
879874
}
@@ -974,11 +969,7 @@ static inline ssize_t do_tty_write(
974969
cond_resched();
975970
}
976971
if (written) {
977-
struct timespec ts;
978-
979-
ts = timespec64_to_timespec(file_inode(file)->i_mtime);
980-
tty_update_time(&ts);
981-
file_inode(file)->i_mtime = timespec_to_timespec64(ts);
972+
tty_update_time(&file_inode(file)->i_mtime);
982973
ret = written;
983974
}
984975
out:

0 commit comments

Comments
 (0)