Skip to content
  • Peter Maydell's avatar
    81b3ddaf
    hw/timer/renesas_tmr: Fix use of uninitialized data in read_tcnt() · 81b3ddaf
    Peter Maydell authored
    
    
    The read_tcnt() function calculates the TCNT register values for the
    two channels of the timer module; it sets these up in the local
    tcnt[] array, and eventually returns either one or both of them,
    depending on whether the access is 8 or 16 bits.  However, not all of
    the code paths through this function set both elements of this array:
    if the guest has programmed the TCCR.CSS register fields to values
    which are either documented as not to be used or which QEMU does not
    implement, then the function will return uninitialized data.  (This
    was spotted by Coverity.)
    
    Add the missing CSS cases to this code, so that we return a
    consistent value instead of uninitialized data, and so the code
    structure indicates what's happening.
    
    Fixes: CID 1429976
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Message-id: 20210219223241.16344-3-peter.maydell@linaro.org
    81b3ddaf
    hw/timer/renesas_tmr: Fix use of uninitialized data in read_tcnt()
    Peter Maydell authored
    
    
    The read_tcnt() function calculates the TCNT register values for the
    two channels of the timer module; it sets these up in the local
    tcnt[] array, and eventually returns either one or both of them,
    depending on whether the access is 8 or 16 bits.  However, not all of
    the code paths through this function set both elements of this array:
    if the guest has programmed the TCCR.CSS register fields to values
    which are either documented as not to be used or which QEMU does not
    implement, then the function will return uninitialized data.  (This
    was spotted by Coverity.)
    
    Add the missing CSS cases to this code, so that we return a
    consistent value instead of uninitialized data, and so the code
    structure indicates what's happening.
    
    Fixes: CID 1429976
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Message-id: 20210219223241.16344-3-peter.maydell@linaro.org
Loading