|
@@ -538,10 +538,23 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
|
|
|
sector_t from = state->parts[p].from;
|
|
|
if (!size)
|
|
|
continue;
|
|
|
+ if (from >= get_capacity(disk)) {
|
|
|
+ printk(KERN_WARNING
|
|
|
+ "%s: p%d ignored, start %llu is behind the end of the disk\n",
|
|
|
+ disk->disk_name, p, (unsigned long long) from);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (from + size > get_capacity(disk)) {
|
|
|
+ /*
|
|
|
+ * we can not ignore partitions of broken tables
|
|
|
+ * created by for example camera firmware, but we
|
|
|
+ * limit them to the end of the disk to avoid
|
|
|
+ * creating invalid block devices
|
|
|
+ */
|
|
|
printk(KERN_WARNING
|
|
|
- "%s: p%d exceeds device capacity\n",
|
|
|
- disk->disk_name, p);
|
|
|
+ "%s: p%d size %llu limited to end of disk\n",
|
|
|
+ disk->disk_name, p, (unsigned long long) size);
|
|
|
+ size = get_capacity(disk) - from;
|
|
|
}
|
|
|
res = add_partition(disk, p, from, size, state->parts[p].flags);
|
|
|
if (res) {
|