diff options
Diffstat (limited to 'net/compat.c')
-rw-r--r-- | net/compat.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/compat.c b/net/compat.c index 1f32866d09b7..17c2710b2b93 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -545,15 +545,20 @@ int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp) | |||
545 | struct compat_timeval __user *ctv = | 545 | struct compat_timeval __user *ctv = |
546 | (struct compat_timeval __user*) userstamp; | 546 | (struct compat_timeval __user*) userstamp; |
547 | int err = -ENOENT; | 547 | int err = -ENOENT; |
548 | struct timeval tv; | ||
548 | 549 | ||
549 | if (!sock_flag(sk, SOCK_TIMESTAMP)) | 550 | if (!sock_flag(sk, SOCK_TIMESTAMP)) |
550 | sock_enable_timestamp(sk); | 551 | sock_enable_timestamp(sk); |
551 | if (sk->sk_stamp.tv_sec == -1) | 552 | tv = ktime_to_timeval(sk->sk_stamp); |
553 | if (tv.tv_sec == -1) | ||
552 | return err; | 554 | return err; |
553 | if (sk->sk_stamp.tv_sec == 0) | 555 | if (tv.tv_sec == 0) { |
554 | do_gettimeofday(&sk->sk_stamp); | 556 | sk->sk_stamp = ktime_get_real(); |
555 | if (put_user(sk->sk_stamp.tv_sec, &ctv->tv_sec) || | 557 | tv = ktime_to_timeval(sk->sk_stamp); |
556 | put_user(sk->sk_stamp.tv_usec, &ctv->tv_usec)) | 558 | } |
559 | err = 0; | ||
560 | if (put_user(tv.tv_sec, &ctv->tv_sec) || | ||
561 | put_user(tv.tv_usec, &ctv->tv_usec)) | ||
557 | err = -EFAULT; | 562 | err = -EFAULT; |
558 | return err; | 563 | return err; |
559 | } | 564 | } |