Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bnx2x: use ktime_get_seconds() for timestamp

commit c48f350ff5e7 "bnx2x: Add MFW dump support" added the
bnx2x_update_mfw_dump() function that reads the current time and stores
it in a 32-bit field that gets passed into a buffer in a fixed format.

This is potentially broken when the epoch overflows in 2038, and
otherwise overflows in 2106. As we're trying to avoid uses of
struct timeval for this reason, I noticed the addition of this
function, and tried to rewrite it in a way that is more explicit
about the overflow and that will keep working once we deprecate
struct timeval.

I assume that it is not possible to change the ABI any more, otherwise
we should try to use a 64-bit field for the seconds right away.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Yuval Mintz <Yuval.Mintz@qlogic.com>
Cc: Ariel Elior <Ariel.Elior@qlogic.com>
Acked-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnd Bergmann and committed by
David S. Miller
a19a19de 8e2d61e0

+2 -4
+2 -4
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
··· 3705 3705 3706 3706 void bnx2x_update_mfw_dump(struct bnx2x *bp) 3707 3707 { 3708 - struct timeval epoc; 3709 3708 u32 drv_ver; 3710 3709 u32 valid_dump; 3711 3710 3712 3711 if (!SHMEM2_HAS(bp, drv_info)) 3713 3712 return; 3714 3713 3715 - /* Update Driver load time */ 3716 - do_gettimeofday(&epoc); 3717 - SHMEM2_WR(bp, drv_info.epoc, epoc.tv_sec); 3714 + /* Update Driver load time, possibly broken in y2038 */ 3715 + SHMEM2_WR(bp, drv_info.epoc, (u32)ktime_get_real_seconds()); 3718 3716 3719 3717 drv_ver = bnx2x_update_mng_version_utility(DRV_MODULE_VERSION, true); 3720 3718 SHMEM2_WR(bp, drv_info.drv_ver, drv_ver);