• Mathias Nyman's avatar
    thunderbolt: usb4: Fix NVM read buffer bounds and offset issue · 22c7a18e
    Mathias Nyman authored
    Up to 64 bytes of data can be read from NVM in one go.
    Read address must be dword aligned. Data is read into a local buffer.
    
    If caller asks to read data starting at an unaligned address then full
    dword is anyway read from NVM into a local buffer. Data is then copied
    from the local buffer starting at the unaligned offset to the caller
    buffer.
    
    In cases where asked data length + unaligned offset is over 64 bytes
    we need to make sure we don't read past the 64 bytes in the local
    buffer when copying to caller buffer, and make sure that we don't
    skip copying unaligned offset bytes from local buffer anymore after
    the first round of 64 byte NVM data read.
    
    Fixes: b0407983 ("thunderbolt: Add initial support for USB4")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
    Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
    22c7a18e
usb4.c 43.6 KB