[Linux-ia64] [PATCH] linux/fs/partitions/efi.c error handling

From: Alex Williamson <alex_williamson_at_hp.com>
Date: 2002-02-15 04:11:19
   I was testing w/ some disks that appear to have bad partition
tables and was getting the following error messages:

SCSI device sdt: 35566480 512-byte hdwr sectors (18210 MB)
 sdt:<4>  Warning: Disk has a valid GPT signature but invalid PMBR.
  Use GNU Parted to correct disk.

Unfortunately, that's not where the problem stopped.  I got
random pointer dereference problems, and was apparently having
data structures freed out from under them.  Turns out the
find_valid_gpt() was freeing data structures more than once and
passing back pointers to freed structures.  Patch below.

	Alex

--
Alex Williamson                                  Linux Development Lab
alex_williamson@hp.com                                 Hewlett Packard
970-898-9173                                          Fort Collins, CO
--- linux/fs/partitions/efi.c~	25 Jan 2002 20:15:06 -0000	1.2
+++ linux/fs/partitions/efi.c	14 Feb 2002 16:50:07 -0000
@@ -549,10 +549,14 @@ find_valid_gpt(struct gendisk *hd, struc
 
 		*gpt = pgpt;
 		*ptes = pptes;
-		if (agpt)
+		if (agpt) {
 			kfree(agpt);
-		if (aptes)
+			agpt = NULL;
+		}
+		if (aptes) {
 			kfree(aptes);
+			aptes = NULL;
+		}
 	} /* if primary is valid */
 	else {
 		/* Primary GPT is bad, check the Alternate GPT */
@@ -602,6 +606,8 @@ find_valid_gpt(struct gendisk *hd, struc
 	/* Both primary and alternate GPTs are bad, and/or PMBR is invalid.
 	 * This isn't our disk, return 0.
 	 */
+	*gpt = *ptes = NULL;
+
 	if (pgpt) {
 		kfree(pgpt);
 		pgpt = NULL;
Received on Thu Feb 14 09:23:14 2002

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:07 EST