Skip to content

Commit 7777f47

Browse files
Li Lingfengaxboe
authored andcommitted
block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
Commit 1a721de ("block: don't add or resize partition on the disk with GENHD_FL_NO_PART") prevented all operations about partitions on disks with GENHD_FL_NO_PART in blkpg_do_ioctl() since they are meaningless. However, it changed error code in some scenarios. So move checking GENHD_FL_NO_PART to bdev_add_partition() to eliminate impact. Fixes: 1a721de ("block: don't add or resize partition on the disk with GENHD_FL_NO_PART") Reported-by: Allison Karlitskaya <[email protected]> Closes: https://lore.kernel.org/all/CAOYeF9VsmqKMcQjo1k6YkGNujwN-nzfxY17N3F-CMikE1tYp+w@mail.gmail.com/ Signed-off-by: Li Lingfeng <[email protected]> Reviewed-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 6613476 commit 7777f47

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

block/ioctl.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ static int blkpg_do_ioctl(struct block_device *bdev,
2020
struct blkpg_partition p;
2121
sector_t start, length;
2222

23-
if (disk->flags & GENHD_FL_NO_PART)
24-
return -EINVAL;
2523
if (!capable(CAP_SYS_ADMIN))
2624
return -EACCES;
2725
if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))

block/partitions/core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
439439
goto out;
440440
}
441441

442+
if (disk->flags & GENHD_FL_NO_PART) {
443+
ret = -EINVAL;
444+
goto out;
445+
}
446+
442447
if (partition_overlaps(disk, start, length, -1)) {
443448
ret = -EBUSY;
444449
goto out;

0 commit comments

Comments
 (0)