Skip to contentSkip to conversation

linux/fs/partitions/efi.c error handling

PATCH Applied Alex Williamson 6 participants 39 messages Feb 14, 2002 – Feb 16, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#1 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#2 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#3 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#4 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#5 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#6 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#7 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#8 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#9 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#10 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#11 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#12 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#13 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#14 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#15 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#16 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#17 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#18 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#19 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#20 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#21 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#22 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#23 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#24 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#25 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#26 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#27 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#28 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#29 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#30 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#31 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#32 lore raw

PATCH 1/1 linux/fs/partitions/efi.c error handling

In reply to Alex Williamson

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
[email protected] Hewlett Packard
970-898-9173 Fort Collins, CO

fs/partitions/efi.c renamed from fs/partitions/efi.c~ +8 -2
@@ -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;
#33 lore raw
In reply to Alex Williamson
Quoted 4 lines

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.

Mia culpa. Pass the brown paper bag. Thanks for the fix. -Matt

--
Matt Domsch
Sr. Software Engineer
Dell Linux Solutions www.dell.com/linux
#1 US Linux Server provider with 24.5% (IDC Dec 2001) #2 Worldwide Linux Server provider with 18.2% (IDC Dec 2001)

#34 lore raw
In reply to Alex Williamson
Quoted 10 lines · Alex Williamson

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.

Is it just me or is this getting resent every couple of hours? ... something has gone horribly wrong.

Cheers,
Bill

#35 lore raw
In reply to Alex Williamson
Quoted 4 lines · William Lee Irwin III

Is it just me or is this getting resent every couple of hours? ... something has gone horribly wrong.

Yes it has, and I apologize. I wish it was a machine close enough
that I could just yank the LAN tap, but unfortunately it's on the other side of the HP network. Seems that a combination of a poorly configured HP server and a slow sourceforge mail server are having just enough trouble talking that the mail gets through but the acknowledgement gets dropped. What was that about pass the brown paper bag? Sorry folks, I'll try to get the message killed ASAP. Thanks,

Alex

#36 lore raw
In reply to Alex Williamson
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Alex Williamson

Alex> I was testing w/ some disks that appear to have bad
Alex> partition tables and was getting the following error messages:

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

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

Applied, thanks!

	--david
#37 lore raw
In reply to Alex Williamson
Quoted 15 lines · David Mosberger
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · Alex Williamson

Alex> I was testing w/ some disks that appear to have bad
Alex> partition tables and was getting the following error messages:

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

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

Quoted 3 lines

Applied, thanks!

	--david

So the key to getting things applied to keep sending the exact same message over and over and over?

:-)

John

#38 lore raw
In reply to Alex Williamson
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line · John Hesterberg

John> So the key to getting things applied to keep sending the exact John> same message over and over and over?

John> :-)

Actually, I saw Alex's mail only once. If you use procmail, I highly recommend adding the following rule near the top of your .procmailrc:

# suppress duplicate mails (e.g., mail sent to multiple mailing lists)
:0 Wh: msgid.lock
| formail -D 32768 mail/msgid.cache

This keeps off all those annoying replicants when cc'd both explicitly and on mailing-lists.

	--david