net: ipv4: Fix truncated timestamp returned by inet_current_timestamp()
authorDeepa Dinamani <deepa.kernel@gmail.com>
Tue, 22 Mar 2016 01:21:26 +0000 (18:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 22 Mar 2016 02:56:38 +0000 (22:56 -0400)
The millisecond timestamps returned by the function is
converted to network byte order by making a call to htons().
htons() only returns __be16 while __be32 is required here.

This was identified by the sparse warning from the buildbot:
net/ipv4/af_inet.c:1405:16: sparse: incorrect type in return
    expression (different base types)
net/ipv4/af_inet.c:1405:16: expected restricted __be32
net/ipv4/af_inet.c:1405:16: got restricted __be16 [usertype] <noident>

Change the function to use htonl() to return the correct __be32 type
instead so that the millisecond value doesn't get truncated.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: James Morris <jmorris@namei.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Fixes: 822c868532ca ("net: ipv4: Convert IP network timestamps to be y2038 safe")
Reported-by: Fengguang Wu <fengguang.wu@intel.com> [0-day test robot]
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/af_inet.c

index 0fefba64ee79426b76782cef2da50e050b0cd59c..9e481992dbaef2d8bd7e9c7b870add4d4330fd99 100644 (file)
@@ -1415,7 +1415,7 @@ __be32 inet_current_timestamp(void)
        msecs += (u32)ts.tv_nsec / NSEC_PER_MSEC;
 
        /* Convert to network byte order. */
-       return htons(msecs);
+       return htonl(msecs);
 }
 EXPORT_SYMBOL(inet_current_timestamp);