Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Nov 2008 16:51:33 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r184734 - head/sys/geom/part
Message-ID:  <200811061651.mA6GpX1k060674@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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@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 "



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811061651.mA6GpX1k060674>