x86/hvm: Fix shifting in stdvga_mem_read()
PATCH 1/1 x86/hvm: Fix shifting in stdvga_mem_read()
stdvga_mem_read() has a return type of uint8_t, which promotes to int rather than unsigned int. Shifting by 24 may hit the sign bit.
Spotted by Coverity.
Signed-off-by Andrew Cooper <[email protected]>
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
--- xen/arch/x86/hvm/stdvga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/stdvga.c +1 -1
@@ -322,7 +322,7 @@ static int stdvga_mem_read(const struct hvm_io_handler *handler, data =stdvga_mem_readb (addr); data |=stdvga_mem_readb (addr +1 ) <<8 ; data |=stdvga_mem_readb (addr +2 ) <<16 ; - data |=stdvga_mem_readb (addr +3 ) <<24 ; + data |= (uint32_t )stdvga_mem_readb (addr +3 ) <<24 ;break ;case 8 :
Signature · 1 line
2.11.0
Quoted 6 lines · Andrew Cooper
stdvga_mem_read()has a return type ofuint8_t, which promotes to int rather than unsigned int. Shifting by 24 may hit the sign bit.Spotted by Coverity.
Signed-off-by Andrew Cooper <[email protected]>
Reviewed-by Jan Beulich <[email protected]>