diff options
author | Sami Kerola | 2019-05-18 19:43:08 +0200 |
---|---|---|
committer | Sami Kerola | 2019-05-18 19:43:08 +0200 |
commit | 23df051030add5f755633fc7a88ea66404f26adf (patch) | |
tree | 5725ee66aa72640e4524679101f8c57f3227c828 /sys-utils | |
parent | include/strutils: fix potential null pointer dereference (diff) | |
download | kernel-qcow2-util-linux-23df051030add5f755633fc7a88ea66404f26adf.tar.gz kernel-qcow2-util-linux-23df051030add5f755633fc7a88ea66404f26adf.tar.xz kernel-qcow2-util-linux-23df051030add5f755633fc7a88ea66404f26adf.zip |
lscpu: fix floating point exception
As the title tells this change indeed fixes floating point exception, but
post processing as value overwrite feels a wrong. Possibly something in
input is making cpu set count to go wrong, but I could not get my head
around what could it be. Anyway avoiding division by zero seems better than
crashing so lets do this atleast for now.
Caused-by: e5f721132ec8b8c933a396d8dcb3efcb67854f13
Addresses: https://github.com/karelzak/util-linux/issues/788
Reported-by: Lars Wendler <polynomial-c@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/lscpu.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index ca7f6a037..7f6277f00 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -1925,6 +1925,8 @@ static int get_cache_full_size(struct lscpu_desc *desc, /* Correction for CPU threads */ if (desc->nthreads > desc->ncores) nshares /= (desc->nthreads / desc->ncores); + if (nshares < 1) + nshares = 1; *res = (desc->ncores / nshares) * ca->size; return 0; |