aboutsummaryrefslogtreecommitdiffstats
path: root/block/ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/ioctl.c')
-rw-r--r--block/ioctl.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/block/ioctl.c b/block/ioctl.c
index eb046aeede8a..d77f5e280a6e 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -15,7 +15,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
15 struct blkpg_ioctl_arg a; 15 struct blkpg_ioctl_arg a;
16 struct blkpg_partition p; 16 struct blkpg_partition p;
17 long long start, length; 17 long long start, length;
18 int part; 18 int partno;
19 int i; 19 int i;
20 int err; 20 int err;
21 21
@@ -28,8 +28,8 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
28 disk = bdev->bd_disk; 28 disk = bdev->bd_disk;
29 if (bdev != bdev->bd_contains) 29 if (bdev != bdev->bd_contains)
30 return -EINVAL; 30 return -EINVAL;
31 part = p.pno; 31 partno = p.pno;
32 if (part <= 0 || part >= disk->minors) 32 if (partno <= 0 || partno >= disk->minors)
33 return -EINVAL; 33 return -EINVAL;
34 switch (a.op) { 34 switch (a.op) {
35 case BLKPG_ADD_PARTITION: 35 case BLKPG_ADD_PARTITION:
@@ -59,13 +59,14 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
59 } 59 }
60 } 60 }
61 /* all seems OK */ 61 /* all seems OK */
62 err = add_partition(disk, part, start, length, ADDPART_FLAG_NONE); 62 err = add_partition(disk, partno, start, length,
63 ADDPART_FLAG_NONE);
63 mutex_unlock(&bdev->bd_mutex); 64 mutex_unlock(&bdev->bd_mutex);
64 return err; 65 return err;
65 case BLKPG_DEL_PARTITION: 66 case BLKPG_DEL_PARTITION:
66 if (!disk->part[part-1]) 67 if (!disk->part[partno - 1])
67 return -ENXIO; 68 return -ENXIO;
68 bdevp = bdget_disk(disk, part); 69 bdevp = bdget_disk(disk, partno);
69 if (!bdevp) 70 if (!bdevp)
70 return -ENOMEM; 71 return -ENOMEM;
71 mutex_lock(&bdevp->bd_mutex); 72 mutex_lock(&bdevp->bd_mutex);
@@ -79,7 +80,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
79 invalidate_bdev(bdevp); 80 invalidate_bdev(bdevp);
80 81
81 mutex_lock_nested(&bdev->bd_mutex, 1); 82 mutex_lock_nested(&bdev->bd_mutex, 1);
82 delete_partition(disk, part); 83 delete_partition(disk, partno);
83 mutex_unlock(&bdev->bd_mutex); 84 mutex_unlock(&bdev->bd_mutex);
84 mutex_unlock(&bdevp->bd_mutex); 85 mutex_unlock(&bdevp->bd_mutex);
85 bdput(bdevp); 86 bdput(bdevp);