lscpu: fix NULL dereference
Fixes: https://github.com/karelzak/util-linux/issues/1401 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
692167ff5e
commit
ebd4749115
|
@ -561,7 +561,7 @@ int lscpu_read_cpuinfo(struct lscpu_cxt *cxt)
|
||||||
/* Set the default type to CPUs which are missing (or not parsed)
|
/* Set the default type to CPUs which are missing (or not parsed)
|
||||||
* in cpuinfo */
|
* in cpuinfo */
|
||||||
ct = lscpu_cputype_get_default(cxt);
|
ct = lscpu_cputype_get_default(cxt);
|
||||||
for (i = 0; i < cxt->npossibles; i++) {
|
for (i = 0; ct && i < cxt->npossibles; i++) {
|
||||||
struct lscpu_cpu *cpu = cxt->cpus[i];
|
struct lscpu_cpu *cpu = cxt->cpus[i];
|
||||||
|
|
||||||
if (cpu && !cpu->type)
|
if (cpu && !cpu->type)
|
||||||
|
|
|
@ -966,7 +966,7 @@ static void print_summary(struct lscpu_cxt *cxt)
|
||||||
*(p - 2) = '\0';
|
*(p - 2) = '\0';
|
||||||
add_summary_s(tb, sec, _("CPU op-mode(s):"), buf);
|
add_summary_s(tb, sec, _("CPU op-mode(s):"), buf);
|
||||||
}
|
}
|
||||||
if (ct->addrsz)
|
if (ct && ct->addrsz)
|
||||||
add_summary_s(tb, sec, _("Address sizes:"), ct->addrsz);
|
add_summary_s(tb, sec, _("Address sizes:"), ct->addrsz);
|
||||||
#if !defined(WORDS_BIGENDIAN)
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
add_summary_s(tb, sec, _("Byte Order:"), "Little Endian");
|
add_summary_s(tb, sec, _("Byte Order:"), "Little Endian");
|
||||||
|
@ -1008,9 +1008,9 @@ static void print_summary(struct lscpu_cxt *cxt)
|
||||||
sec = NULL;
|
sec = NULL;
|
||||||
|
|
||||||
/* Section: cpu type description */
|
/* Section: cpu type description */
|
||||||
if (ct->vendor)
|
if (ct && ct->vendor)
|
||||||
sec = add_summary_s(tb, NULL, _("Vendor ID:"), ct->vendor);
|
sec = add_summary_s(tb, NULL, _("Vendor ID:"), ct->vendor);
|
||||||
if (ct->bios_vendor)
|
if (ct && ct->bios_vendor)
|
||||||
add_summary_s(tb, sec, _("BIOS Vendor ID:"), ct->bios_vendor);
|
add_summary_s(tb, sec, _("BIOS Vendor ID:"), ct->bios_vendor);
|
||||||
|
|
||||||
for (i = 0; i < cxt->ncputypes; i++)
|
for (i = 0; i < cxt->ncputypes; i++)
|
||||||
|
|
Loading…
Reference in New Issue