提交 04ebd4ae 编写于 作者: A Abdel Benamrouche 提交者: Linus Torvalds

block/ioctl.c and fs/partition/check.c: check value returned by add_partition()

Now that add_partition() has been aught to propagate errors, let's check them.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: NAbdel Benamrouche <draconux@gmail.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 d805dda4
...@@ -17,6 +17,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user ...@@ -17,6 +17,7 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
long long start, length; long long start, length;
int part; int part;
int i; int i;
int err;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
...@@ -61,9 +62,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user ...@@ -61,9 +62,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
} }
} }
/* all seems OK */ /* all seems OK */
add_partition(disk, part, start, length, ADDPART_FLAG_NONE); err = add_partition(disk, part, start, length, ADDPART_FLAG_NONE);
mutex_unlock(&bdev->bd_mutex); mutex_unlock(&bdev->bd_mutex);
return 0; return err;
case BLKPG_DEL_PARTITION: case BLKPG_DEL_PARTITION:
if (!disk->part[part-1]) if (!disk->part[part-1])
return -ENXIO; return -ENXIO;
......
...@@ -499,10 +499,16 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -499,10 +499,16 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
if (!size) if (!size)
continue; continue;
if (from + size > get_capacity(disk)) { if (from + size > get_capacity(disk)) {
printk(" %s: p%d exceeds device capacity\n", printk(KERN_ERR " %s: p%d exceeds device capacity\n",
disk->disk_name, p); disk->disk_name, p);
continue;
}
res = add_partition(disk, p, from, size, state->parts[p].flags);
if (res) {
printk(KERN_ERR " %s: p%d could not be added: %d\n",
disk->disk_name, p, -res);
continue;
} }
add_partition(disk, p, from, size, state->parts[p].flags);
#ifdef CONFIG_BLK_DEV_MD #ifdef CONFIG_BLK_DEV_MD
if (state->parts[p].flags & ADDPART_FLAG_RAID) if (state->parts[p].flags & ADDPART_FLAG_RAID)
md_autodetect_dev(bdev->bd_dev+p); md_autodetect_dev(bdev->bd_dev+p);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册