From 5ebda149d87c69c5123e3ae2ba6f8a2c0f359121 Mon Sep 17 00:00:00 2001 From: marcel Date: Thu, 6 Nov 2008 16:51:33 +0000 Subject: 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 MFC after: 1 week --- sys/geom/part/g_part_gpt.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sys/geom') 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 " -- cgit v1.1