diff options
author | marcel <marcel@FreeBSD.org> | 2008-11-06 16:51:33 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2008-11-06 16:51:33 +0000 |
commit | 5ebda149d87c69c5123e3ae2ba6f8a2c0f359121 (patch) | |
tree | ceff9e1b1d1af7a072a16254b589474d9b2d3323 /sys/geom/part | |
parent | 1d778ddbeb9b13388425dbe2dba709328cc37d59 (diff) | |
download | FreeBSD-src-5ebda149d87c69c5123e3ae2ba6f8a2c0f359121.zip FreeBSD-src-5ebda149d87c69c5123e3ae2ba6f8a2c0f359121.tar.gz |
Fix a panic caused by a corrupted table when the header is
still valid. We were checking the state of the header and
not the table.
PR: 119868
Based on a patch from: Jaakko Heinonen <jh@saunalahti.fi>
MFC after: 1 week
Diffstat (limited to 'sys/geom/part')
-rw-r--r-- | sys/geom/part/g_part_gpt.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index 77d018b..7bdfa07 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -625,13 +625,16 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp) if (table->state[GPT_ELT_PRIHDR] == GPT_STATE_OK && table->state[GPT_ELT_SECHDR] == GPT_STATE_OK && !gpt_matched_hdrs(&prihdr, &sechdr)) { - if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK) + if (table->state[GPT_ELT_PRITBL] == GPT_STATE_OK) { table->state[GPT_ELT_SECHDR] = GPT_STATE_INVALID; - else + table->state[GPT_ELT_SECTBL] = GPT_STATE_MISSING; + } else { table->state[GPT_ELT_PRIHDR] = GPT_STATE_INVALID; + table->state[GPT_ELT_PRITBL] = GPT_STATE_MISSING; + } } - if (table->state[GPT_ELT_PRIHDR] != GPT_STATE_OK) { + if (table->state[GPT_ELT_PRITBL] != GPT_STATE_OK) { printf("GEOM: %s: the primary GPT table is corrupt or " "invalid.\n", pp->name); printf("GEOM: %s: using the secondary instead -- recovery " @@ -641,7 +644,7 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp) if (pritbl != NULL) g_free(pritbl); } else { - if (table->state[GPT_ELT_SECHDR] != GPT_STATE_OK) { + if (table->state[GPT_ELT_SECTBL] != GPT_STATE_OK) { printf("GEOM: %s: the secondary GPT table is corrupt " "or invalid.\n", pp->name); printf("GEOM: %s: using the primary only -- recovery " |