mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
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>
This commit is contained in:
parent
eeaa671505
commit
4f938cbd90
1 changed files with 1 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue