• Gustavo A. R. Silva's avatar
    hwmon: (occ) Fix potential integer overflow · b0407d82
    Gustavo A. R. Silva authored
    Cast get_unaligned_be32(...) to u64 in order to give the compiler
    complete information about the proper arithmetic to use and avoid
    a potential integer overflow.
    
    Notice that such function call is used in contexts that expect
    expressions of type u64 (64 bits, unsigned); and the following
    expressions are currently being evaluated using 32-bit
    arithmetic:
    
    val = get_unaligned_be32(&power->update_tag) *
                            occ->powr_sample_time_us;
    
    val = get_unaligned_be32(&power->vdn.update_tag) *
                            occ->powr_sample_time_us;
    
    Addresses-Coverity-ID: 1442357 ("Unintentional integer overflow")
    Addresses-Coverity-ID: 1442476 ("Unintentional integer overflow")
    Addresses-Coverity-ID: 1442508 ("Unintentional integer overflow")
    Fixes: ff692d80b2e2 ("hwmon (occ): Add sensor types and versions")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
    Reviewed-by: default avatarEddie James <eajames@linux.ibm.com>
    Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
    b0407d82
common.c 25.8 KB