diff options
author | Karel Zak | 2012-02-01 12:26:20 +0100 |
---|---|---|
committer | Karel Zak | 2012-02-01 12:26:32 +0100 |
commit | 701e2b8e53a00e4006f733c46442871e4cd8e6c0 (patch) | |
tree | 423074392c0aa6451ceb5330f5282ef628fe4f19 /sys-utils/lscpu.c | |
parent | cfdisk: wctomb() returns -1 on error (diff) | |
download | kernel-qcow2-util-linux-701e2b8e53a00e4006f733c46442871e4cd8e6c0.tar.gz kernel-qcow2-util-linux-701e2b8e53a00e4006f733c46442871e4cd8e6c0.tar.xz kernel-qcow2-util-linux-701e2b8e53a00e4006f733c46442871e4cd8e6c0.zip |
chcpu: check get_max_number_of_cpus() result properly
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index a9ca2fe59..6a74c4eb7 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -383,9 +383,10 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod) else if (mod->system == SYSTEM_LIVE) /* the root is '/' so we are working with data from the current kernel */ maxcpus = get_max_number_of_cpus(); - else - /* we are reading some /sys snapshot instead of the real /sys, - * let's use any crazy number... */ + + if (maxcpus <= 0) + /* error or we are reading some /sys snapshot instead of the + * real /sys, let's use any crazy number... */ maxcpus = desc->ncpus > 2048 ? desc->ncpus : 2048; /* get mask for online CPUs */ |