block: clarify badblocks lifetime
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>
diff --git a/block/badblocks.c b/block/badblocks.c
index fabf6b6..37e5c0a 100644
--- a/block/badblocks.c
+++ b/block/badblocks.c
@@ -555,6 +555,8 @@
*/
void badblocks_exit(struct badblocks *bb)
{
+ if (!bb)
+ return;
kfree(bb->page);
bb->page = NULL;
}