Skip to content

Commit

Permalink
block: clarify badblocks lifetime
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
djbw committed Jan 9, 2016
1 parent d3b407f commit 20a308f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 2 additions & 0 deletions block/badblocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ EXPORT_SYMBOL_GPL(badblocks_init);
*/
void badblocks_exit(struct badblocks *bb)
{
if (!bb)
return;
kfree(bb->page);
bb->page = NULL;
}
Expand Down
5 changes: 0 additions & 5 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 20a308f

Please sign in to comment.