• Roland Dreier's avatar
    IB/mthca: Avoid integer overflow when dealing with profile size · 19773539
    Roland Dreier authored
    mthca_make_profile() returns the size in bytes of the HCA context
    layout it creates, or a negative value if an error occurs.  However,
    the return value is declared as u64 and the memfree initialization
    path casts this value to int to test if it is negative.  This makes it
    think incorrectly than an error has occurred if the context size
    happens to be bigger than 2GB, since this turns into a negative int.
    
    Fix this by having mthca_make_profile() return an s64 and testing
    for an error by checking whether this 64-bit value itself is negative.
    Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
    19773539
mthca_profile.c 9.2 KB