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

Robert Noland rnoland at FreeBSD.org
Thu Nov 12 16:28:39 UTC 2009


Author: rnoland
Date: Thu Nov 12 16:28:39 2009
New Revision: 199228
URL: http://svn.freebsd.org/changeset/base/199228

Log:
  We need to allocate space for the header in the create path also.
  
  This fixes a null pointer dereference with "gpart create -s GPT" after
  the previous commit.
  
  Reported by:	Yuri Pankov
  Pointyhat to:	me
  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 12 15:59:05 2009	(r199227)
+++ head/sys/geom/part/g_part_gpt.c	Thu Nov 12 16:28:39 2009	(r199228)
@@ -444,6 +444,9 @@ g_part_gpt_create(struct g_part_table *b
 	table->lba[GPT_ELT_SECHDR] = last;
 	table->lba[GPT_ELT_SECTBL] = last - tblsz;
 
+	/* Allocate space for the header */
+	table->hdr = g_malloc(sizeof(struct gpt_hdr), M_WAITOK | M_ZERO);
+
 	bcopy(GPT_HDR_SIG, table->hdr->hdr_sig, sizeof(table->hdr->hdr_sig));
 	table->hdr->hdr_revision = GPT_HDR_REVISION;
 	table->hdr->hdr_size = offsetof(struct gpt_hdr, padding);


More information about the svn-src-all mailing list