[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/44] host-utils: Fix overflow detection in divu128()
From: |
David Gibson |
Subject: |
[PULL 01/44] host-utils: Fix overflow detection in divu128() |
Date: |
Thu, 30 Sep 2021 15:43:43 +1000 |
From: Luis Pires <luis.pires@eldorado.org.br>
The previous code didn't detect overflows if the high 64-bit
of the dividend were equal to the 64-bit divisor. In that case,
64 bits wouldn't be enough to hold the quotient.
Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20210910112624.72748-2-luis.pires@eldorado.org.br>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
util/host-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/host-utils.c b/util/host-utils.c
index 7b9322071d..a789a11b46 100644
--- a/util/host-utils.c
+++ b/util/host-utils.c
@@ -102,7 +102,7 @@ int divu128(uint64_t *plow, uint64_t *phigh, uint64_t
divisor)
*plow = dlo / divisor;
*phigh = dlo % divisor;
return 0;
- } else if (dhi > divisor) {
+ } else if (dhi >= divisor) {
return 1;
} else {
--
2.31.1
- [PULL 00/44] ppc-for-6.2 queue 20210930, David Gibson, 2021/09/30
- [PULL 01/44] host-utils: Fix overflow detection in divu128(),
David Gibson <=
- [PULL 05/44] ppc/spapr: Add a POWER10 DD2 CPU, David Gibson, 2021/09/30
- [PULL 11/44] docs/system: ppc: Update the URL for OpenPOWER firmware images, David Gibson, 2021/09/30
- [PULL 04/44] i386/kvm: Replace abs64() with uabs64() from host-utils, David Gibson, 2021/09/30
- [PULL 10/44] ppc/pnv: Rename "id" to "quad-id" in PnvQuad, David Gibson, 2021/09/30
- [PULL 06/44] ppc/pnv: Add a comment on the "primary-topology-index" property, David Gibson, 2021/09/30
- [PULL 02/44] host-utils: fix missing zero-extension in divs128, David Gibson, 2021/09/30
- [PULL 07/44] ppc/pnv: Remove useless variable, David Gibson, 2021/09/30
- [PULL 14/44] memory_hotplug.c: handle dev->id = NULL in acpi_memory_hotplug_write(), David Gibson, 2021/09/30
- [PULL 16/44] spapr_drc.c: do not error_report() when drc->dev->id == NULL, David Gibson, 2021/09/30
- [PULL 03/44] host-utils: introduce uabs64(), David Gibson, 2021/09/30