Merge master.kernel.org:/home/rmk/linux-2.6-arm
[sfrench/cifs-2.6.git] / block / genhd.c
index 397960cf26afcd61fc7c2bba2365944c8485c767..e1eadcc9546a72ec0d1c76d933143767dd357536 100644 (file)
@@ -1087,6 +1087,14 @@ dev_t blk_lookup_devt(const char *name, int partno)
                if (strcmp(dev_name(dev), name))
                        continue;
 
+               if (partno < disk->minors) {
+                       /* We need to return the right devno, even
+                        * if the partition doesn't exist yet.
+                        */
+                       devt = MKDEV(MAJOR(dev->devt),
+                                    MINOR(dev->devt) + partno);
+                       break;
+               }
                part = disk_get_part(disk, partno);
                if (part) {
                        devt = part_devt(part);