Skip to content

Commit 1a721de

Browse files
Li Lingfengaxboe
authored andcommitted
block: don't add or resize partition on the disk with GENHD_FL_NO_PART
Commit a33df75 ("block: use an xarray for disk->part_tbl") remove disk_expand_part_tbl() in add_partition(), which means all kinds of devices will support extended dynamic `dev_t`. However, some devices with GENHD_FL_NO_PART are not expected to add or resize partition. Fix this by adding check of GENHD_FL_NO_PART before add or resize partition. Fixes: a33df75 ("block: use an xarray for disk->part_tbl") Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20230831075900.1725842-1-lilingfeng@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0d997f1 commit 1a721de

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

block/ioctl.c

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

23+
if (disk->flags & GENHD_FL_NO_PART)
24+
return -EINVAL;
2325
if (!capable(CAP_SYS_ADMIN))
2426
return -EACCES;
2527
if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))

0 commit comments

Comments
 (0)