[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer ov
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer overflow |
Date: |
Thu, 31 May 2018 19:12:32 +0200 |
From: Peter Maydell <address@hidden>
Coverity complains about qemu_memfd_create() (CID 1385858) because
we calculate a bit position htsize which could be up to 63, but
then use it in "1 << htsize" which is a 32-bit integer calculation
and could push the 1 off the top of the value.
Silence the complaint bu using "1ULL"; this isn't a bug in
practice since a hugetlbsize of 4GB is not very plausible.
Signed-off-by: Peter Maydell <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/memfd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/memfd.c b/util/memfd.c
index b3ecbac19e..d248a53c3c 100644
--- a/util/memfd.c
+++ b/util/memfd.c
@@ -66,7 +66,7 @@ int qemu_memfd_create(const char *name, size_t size, bool
hugetlb,
{
int htsize = hugetlbsize ? ctz64(hugetlbsize) : 0;
- if (htsize && 1 << htsize != hugetlbsize) {
+ if (htsize && 1ULL << htsize != hugetlbsize) {
error_setg(errp, "Hugepage size must be a power of 2");
return -1;
}
--
2.17.0
- [Qemu-devel] [PULL 21/53] hw/i386/pc: Remove unused include, (continued)
- [Qemu-devel] [PULL 21/53] hw/i386/pc: Remove unused include, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 20/53] hw/hppa: Remove unused include, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 23/53] hw: Clean "hw/devices.h" includes, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 24/53] qom: Document qom/device-list-properties implementation specific, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 25/53] qom: support orphan objects in object_get_canonical_path, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 26/53] virtio: free MemoryRegionCache when initialization fails, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 27/53] memory.h: Fix typo in documentation comment, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 28/53] memory: get rid of memory_region_init_reservation, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 30/53] hw/isa/superio: Fix inconsistent use of Chardev->be, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 31/53] mux: fix ctrl-a b again, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 32/53] memfd: Avoid Coverity warning about integer overflow,
Paolo Bonzini <=
- [Qemu-devel] [PULL 33/53] exec.c: Initialize sa_flags passed to sigaction(), Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 29/53] memory: delete struct AddressSpaceOps, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 36/53] qemu-options: Mark the non-functional -clock option as deprecated, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 35/53] WHPX: fix some compiler warnings, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 37/53] tcg: remove softfloat from --disable-tcg builds, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 34/53] WHPX: dynamically load WHP libraries, Paolo Bonzini, 2018/05/31
- [Qemu-devel] [PULL 39/53] ipmi: Use proper struct reference for KCS vmstate, Paolo Bonzini, 2018/05/31