Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

md: move freeing of badblocks.page into md_rdev_clear

This ensures that it is always freed - there were case where
we failed to free the page.

Reported-by: majianpeng <majianpeng@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information...
commit 4ae18ea85ae287e34480549c8aab59ca837536ff 1 parent f297e70
@neilbrown authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 drivers/md/md.c
View
7 drivers/md/md.c
@@ -814,6 +814,10 @@ void md_rdev_clear(struct md_rdev *rdev)
put_page(rdev->bb_page);
rdev->bb_page = NULL;
}
+ if (rdev->badblocks.page) {
+ kfree(rdev->badblocks.page);
+ rdev->badblocks.page = NULL;
+ }
}
EXPORT_SYMBOL_GPL(md_rdev_clear);
@@ -2189,9 +2193,7 @@ static void unbind_rdev_from_array(struct md_rdev * rdev)
sysfs_remove_link(&rdev->kobj, "block");
sysfs_put(rdev->sysfs_state);
rdev->sysfs_state = NULL;
- kfree(rdev->badblocks.page);
rdev->badblocks.count = 0;
- rdev->badblocks.page = NULL;
/* We need to delay this, otherwise we can deadlock when
* writing to 'remove' to "dev/state". We also need
* to delay it due to rcu usage.
@@ -3323,7 +3325,6 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
if (rdev->bdev)
unlock_rdev(rdev);
md_rdev_clear(rdev);
- kfree(rdev->badblocks.page);
kfree(rdev);
return ERR_PTR(err);
}
Please sign in to comment.
Something went wrong with that request. Please try again.