• Arnd Bergmann's avatar
    scsi: arcmsr: avoid do_gettimeofday · 45596c78
    Arnd Bergmann authored
    The arcmsr uses its own implementation of time_to_tm(), along with
    do_gettimeofday() to read the current time. While the algorithm used
    here is fine in principle, it suffers from two problems:
    
    - it assigns the seconds portion of the timeval to a 32-bit unsigned
      integer that overflows in 2106 even on 64-bit architectures.
    
    - do_gettimeofday() returns a time_t that overflows in 2038 on all
      32-bit systems.
    
    This changes the time retrieval function to ktime_get_real_seconds(),
    which returns a proper 64-bit value, and replaces the open-coded
    time_to_tm() algorithm with a call to the safe time64_to_tm().
    
    I checked way all numbers are indexed and found that months are given in
    range 0..11 while the days are in range 1..31, same as 'struct tm', but
    the year value that the firmware expects starts in 2000 while 'struct
    tm' is based on year 1900, so it needs a small adjustment.
    
    [mkp: checkpatch tweaks]
    
    Fixes: b416c099 ("scsi: arcmsr: Add a function to set date and time to firmware")
    Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
    Acked-by: default avatarChing Huang <ching2048@areca.com.tw>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    45596c78
arcmsr_hba.c 133 KB