svn commit: r184734 - head/sys/geom/part

Marcel Moolenaar marcel at FreeBSD.org
Thu Nov 6 08:51:34 PST 2008


Author: marcel
Date: Thu Nov  6 16:51:33 2008
New Revision: 184734
URL: http://svn.freebsd.org/changeset/base/184734

Log:
  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 at saunalahti.fi>
  MFC after: 1 week

Modified:
  head/sys/geom/part/g_part_gpt.c

Modified: head/sys/geom/part/g_part_gpt.c
==============================================================================
--- head/sys/geom/part/g_part_gpt.c	Thu Nov  6 16:30:38 2008	(r184733)
+++ head/sys/geom/part/g_part_gpt.c	Thu Nov  6 16:51:33 2008	(r184734)
@@ -625,13 +625,16 @@ g_part_gpt_read(struct g_part_table *bas
 	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 *bas
 		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 "


More information about the svn-src-all mailing list