From owner-svn-src-all@FreeBSD.ORG Thu Nov 12 16:28:39 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 72A9D106566B; Thu, 12 Nov 2009 16:28:39 +0000 (UTC) (envelope-from rnoland@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 61FF78FC0A; Thu, 12 Nov 2009 16:28:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nACGSdqs035923; Thu, 12 Nov 2009 16:28:39 GMT (envelope-from rnoland@svn.freebsd.org) Received: (from rnoland@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nACGSdlv035921; Thu, 12 Nov 2009 16:28:39 GMT (envelope-from rnoland@svn.freebsd.org) Message-Id: <200911121628.nACGSdlv035921@svn.freebsd.org> From: Robert Noland Date: Thu, 12 Nov 2009 16:28:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r199228 - head/sys/geom/part X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2009 16:28:39 -0000 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);