• Emmanuel Grumbach's avatar
    iwlwifi: dbg: don't crash if the firmware crashes in the middle of a debug dump · 79f25b10
    Emmanuel Grumbach authored
    We can dump data from the firmware either when it crashes,
    or when the firmware is alive.
    Not all the data is available if the firmware is running
    (like the Tx / Rx FIFOs which are available only when the
    firmware is halted), so we first check that the firmware
    is alive to compute the required size for the dump and then
    fill the buffer with the data.
    
    When we allocate the buffer, we test the STATUS_FW_ERROR
    bit to check if the firmware is alive or not. This bit
    can be changed during the course of the dump since it is
    modified in the interrupt handler.
    
    We hit a case where we allocate the buffer while the
    firmware is sill working, and while we start to fill the
    buffer, the firmware crashes. Then we test STATUS_FW_ERROR
    again and decide to fill the buffer with data like the
    FIFOs even if no room was allocated for this data in the
    buffer. This means that we overflow the buffer that was
    allocated leading to memory corruption.
    
    To fix this, test the STATUS_FW_ERROR bit only once and
    rely on local variables to check if we should dump fifos
    or other firmware components.
    
    Fixes: 04fd2c28 ("iwlwifi: mvm: add rxf and txf to dump data")
    Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
    79f25b10
dbg.c 38 KB