patch-1.3.29 linux/drivers/block/genhd.c

Next file: linux/drivers/net/slip.c
Previous file: linux/arch/i386/mm/init.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.28/linux/drivers/block/genhd.c linux/drivers/block/genhd.c
@@ -79,11 +79,12 @@
 {
 	struct buffer_head *bh;
 	struct partition *p;
-	unsigned long first_sector, this_sector, this_size;
+	unsigned long first_sector, first_size, this_sector, this_size;
 	int mask = (1 << hd->minor_shift) - 1;
 	int i;
 
 	first_sector = hd->part[MINOR(dev)].start_sect;
+	first_size = hd->part[MINOR(dev)].nr_sects;
 	this_sector = first_sector;
 
 	while (1) {
@@ -122,7 +123,13 @@
 		    if (!p->nr_sects || p->sys_ind == EXTENDED_PARTITION)
 		      continue;
 
-		    if (p->start_sect + p->nr_sects > this_size)
+		    /* Check the 3rd and 4th entries -
+		       these sometimes contain random garbage */
+		    if (i >= 2
+			&& p->start_sect + p->nr_sects > this_size
+			&& (this_sector + p->start_sect < first_sector ||
+			    this_sector + p->start_sect + p->nr_sects >
+			     first_sector + first_size))
 		      continue;
 
 		    add_partition(hd, current_minor, this_sector+p->start_sect, p->nr_sects);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this