diff options
author | Cédric Le Goater <clg@redhat.com> | 2025-01-07 14:06:04 +0100 |
---|---|---|
committer | Cédric Le Goater <clg@redhat.com> | 2025-02-11 14:15:19 +0100 |
commit | 6e7998ceb9008e82501c7cf069e5552c7e352c6c (patch) | |
tree | 36f3f0f971350b5d83d252870f5161ba40c8eaa4 | |
parent | ffaf7f0376f8040ce9068d71ae9ae8722505c42e (diff) | |
download | qemu-6e7998ceb9008e82501c7cf069e5552c7e352c6c.zip qemu-6e7998ceb9008e82501c7cf069e5552c7e352c6c.tar.gz qemu-6e7998ceb9008e82501c7cf069e5552c7e352c6c.tar.bz2 |
vfio/igd: Fix potential overflow in igd_gtt_memory_size()
The risk is mainly theoretical since the applied bit mask will keep
the 'ggms' shift value below 3. Nevertheless, let's use a 64 bit
integer type and resolve the coverity issue.
Resolves: Coverity CID 1585908
Fixes: 1e1eac5f3dcd ("vfio/igd: canonicalize memory size calculations")
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Link: https://lore.kernel.org/r/20250107130604.669697-1-clg@redhat.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r-- | hw/vfio/igd.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 0740a5d..b5303ea 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -133,7 +133,7 @@ static uint64_t igd_gtt_memory_size(int gen, uint16_t gmch) } else { ggms = (gmch >> IGD_GMCH_GEN8_GGMS_SHIFT) & IGD_GMCH_GEN8_GGMS_MASK; if (ggms != 0) { - ggms = 1 << ggms; + ggms = 1ULL << ggms; } } |