In vu_blk_discard_write_zeroes(), we read a 32-bit sector count from the descriptor and convert it to a 64-bit byte count. Coverity warns that the left shift is done with 32-bit arithmetic so it might overflow before the conversion to 64-bit happens. Add a cast to avoid this.
Fixes: Coverity CID 1435956 Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> --- Tested with 'make check' and 'make check-acceptance' only. --- block/export/vhost-user-blk-server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/export/vhost-user-blk-server.c b/block/export/vhost-user-blk-server.c index 62672d1cb95..e5749451e65 100644 --- a/block/export/vhost-user-blk-server.c +++ b/block/export/vhost-user-blk-server.c @@ -70,7 +70,7 @@ vu_blk_discard_write_zeroes(BlockBackend *blk, struct iovec *iov, } uint64_t range[2] = { le64_to_cpu(desc.sector) << 9, - le32_to_cpu(desc.num_sectors) << 9 }; + (uint64_t)le32_to_cpu(desc.num_sectors) << 9 }; if (type == VIRTIO_BLK_T_DISCARD) { if (blk_co_pdiscard(blk, range[0], range[1]) == 0) { return 0; -- 2.20.1