]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
block: clarify badblocks lifetime
authorDan Williams <dan.j.williams@intel.com>
Wed, 6 Jan 2016 20:03:41 +0000 (12:03 -0800)
committerDan Duval <dan.duval@oracle.com>
Wed, 7 Dec 2016 17:25:46 +0000 (12:25 -0500)
Orabug: 22913653

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@intel.com>
(cherry picked from commit 20a308f09e0d29ce6f5a4114cc476a998d569bfb)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
block/badblocks.c
block/genhd.c

index fabf6b64c2d17692b511336de3e113c18c3e95e6..37e5c0a2ef6952cc71bd6e0ad1dd789ca83d6b3c 100644 (file)
@@ -555,6 +555,8 @@ EXPORT_SYMBOL_GPL(badblocks_init);
  */
 void badblocks_exit(struct badblocks *bb)
 {
+       if (!bb)
+               return;
        kfree(bb->page);
        bb->page = NULL;
 }
index 37d8f4ab360c7d4396acde3969e8e9d348419adf..5e939bbce8e9d9fdad89ef372f3bf1aafb3b0538 100644 (file)
@@ -667,11 +667,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;