diff options
author | Wu Guanghao <wuguanghao3@huawei.com> | 2022-08-15 09:39:02 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-08-15 09:39:02 -0500 |
commit | ce58e9d5b37c3e408f2b41c8095980490a87f2a4 (patch) | |
tree | 4de8b11e650e9df246c3013d6210e6b14d936430 | |
parent | 6b2e4ec5dc629c064a4f5472afd283faa233ca32 (diff) | |
download | lvm2-ce58e9d5b37c3e408f2b41c8095980490a87f2a4.tar.gz |
_vg_read_raw_area: fix segfault caused by using null pointer
When we tested lvm2, the kernel injected various random faults.
(gdb) bt
...
(gdb) p vg
$1 = (struct volume_group *) 0x0
(gdb) p use_previous_vg
$2 = (unsigned int *) 0x0
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
-rw-r--r-- | lib/format_text/format-text.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 07aaa0b28..c1ccdb031 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -428,7 +428,7 @@ static struct volume_group *_vg_read_raw_area(struct cmd_context *cmd, rlocn->checksum, &when, &desc); - if (!vg && !*use_previous_vg) { + if (!vg && (!use_previous_vg || !*use_previous_vg)) { log_warn("WARNING: Failed to read metadata text at %llu off %llu size %llu VG %s on %s", (unsigned long long)(area->start + rlocn->offset), (unsigned long long)rlocn->offset, |