Skip to content

Commit

Permalink
block: allow deleting zero length partition
Browse files Browse the repository at this point in the history
delete_partition() was noop for zero length partition.  As the
addition code allows creating zero lenght partition and deletion is
assumed to always succeed, this causes memory leak for zero length
partitions.  Allow zero length partitions to end their meaningless
lives.

While at it, allow deleting zero lenght partition via
BLKPG_DEL_PARTITION ioctl too.

Signed-off-by: Tejun Heo <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
htejun authored and Jens Axboe committed Oct 9, 2008
1 parent def4e38 commit ec2cded
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 4 deletions.
2 changes: 0 additions & 2 deletions block/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
case BLKPG_DEL_PARTITION:
if (!disk->part[part-1])
return -ENXIO;
if (disk->part[part - 1]->nr_sects == 0)
return -ENXIO;
bdevp = bdget_disk(disk, part);
if (!bdevp)
return -ENOMEM;
Expand Down
2 changes: 0 additions & 2 deletions fs/partitions/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,6 @@ void delete_partition(struct gendisk *disk, int part)

if (!p)
return;
if (!p->nr_sects)
return;
disk->part[part-1] = NULL;
p->start_sect = 0;
p->nr_sects = 0;
Expand Down

0 comments on commit ec2cded

Please sign in to comment.