[PATCH v3 03/10] block: clarify badblocks lifetime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The badblocks list attached to a gendisk is allocated by the driver
which equates to the driver owning the lifetime of the object.  Do not
automatically free it in del_gendisk(). This is in preparation for
expanding the use of badblocks in libnvdimm drivers and introducing
devm_init_badblocks().

Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
---
 block/badblocks.c |    2 ++
 block/genhd.c     |    5 -----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/block/badblocks.c b/block/badblocks.c
index fabf6b64c2d1..37e5c0a2ef69 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -555,6 +555,8 @@ EXPORT_SYMBOL_GPL(badblocks_init);
  */
 void badblocks_exit(struct badblocks *bb)
 {
+	if (!bb)
+		return;
 	kfree(bb->page);
 	bb->page = NULL;
 }
diff --git a/block/genhd.c b/block/genhd.c
index f463c67e6ba2..aa38cd0a66c7 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -670,11 +670,6 @@ void del_gendisk(struct gendisk *disk)
 	blk_unregister_queue(disk);
 	blk_unregister_region(disk_devt(disk), disk->minors);
 
-	if (disk->bb) {
-		badblocks_exit(disk->bb);
-		kfree(disk->bb);
-	}
-
 	part_stat_set_all(&disk->part0, 0);
 	disk->part0.stamp = 0;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux