]> git.baikalelectronics.ru Git - kernel.git/commit
block: update add_partition() error handling
authorTejun Heo <tj@kernel.org>
Mon, 25 Aug 2008 10:30:16 +0000 (19:30 +0900)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 9 Oct 2008 06:56:04 +0000 (08:56 +0200)
commita0c8e655d0a0a41b0829a442b53dafa9386c7c7a
treeb65315c446ce592e6a0dc521eab9acd92ae61c5e
parent1b1520b69b141d7eab1ef401f0b42215938e09ff
block: update add_partition() error handling

bc625f7b tried to fix error case handling in add_partition() but had a
few problems.

* disk->part[] entry is set early and left dangling if operation
  fails.

* Once device initialized, the last put_device() is responsible for
  freeing all the resources.  The failure path freed part_stats and p
  regardless of put_device() causing double free.

* holders subdir holds reference to the disk device, so failure path
  should remove it to release resources properly which was missing.

This patch fixes the above problems and while at it move partition
slot busy check into add_partition() for completeness and inlines
holders subdirectory creation.  Using separate function for it just
obfuscates the code.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Abdel Benamrouche <draconux@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/ioctl.c
fs/partitions/check.c