summaryrefslogtreecommitdiff
path: root/block/partition-generic.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/partition-generic.c')
-rw-r--r--block/partition-generic.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 5f8db5c5140f..98d60a59b843 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -289,6 +289,13 @@ void delete_partition(struct gendisk *disk, int partno)
kobject_put(part->holder_dir);
device_del(part_to_dev(part));
+ /*
+ * Remove gendisk pointer from idr so that it cannot be looked up
+ * while RCU period before freeing gendisk is running to prevent
+ * use-after-free issues. Note that the device number stays
+ * "in-use" until we really free the gendisk.
+ */
+ blk_invalidate_devt(part_devt(part));
hd_struct_kill(part);
}