aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2018-05-15 18:27:29 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-06-01 15:13:46 +0200
commit4f938cbd90e7cf3004a6877ce579a11a87a4aa33 (patch)
tree672697abcc0d4dd6bb3a1d289951061f3dfe6ca6 /util
parenteeaa6715050ed3f9cbedd322220f31570a503217 (diff)
downloadqemu-4f938cbd90e7cf3004a6877ce579a11a87a4aa33.zip
qemu-4f938cbd90e7cf3004a6877ce579a11a87a4aa33.tar.gz
qemu-4f938cbd90e7cf3004a6877ce579a11a87a4aa33.tar.bz2
memfd: Avoid Coverity warning about integer overflow
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 <peter.maydell@linaro.org> Message-Id: <20180515172729.24564-1-peter.maydell@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/memfd.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util/memfd.c b/util/memfd.c
index b3ecbac..d248a53 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;
}