From 23df051030add5f755633fc7a88ea66404f26adf Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 18 May 2019 18:43:08 +0100 Subject: 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 Signed-off-by: Sami Kerola --- sys-utils/lscpu.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sys-utils/lscpu.c') 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; -- cgit v1.2.3-55-g7522