Skip to content

Commit

Permalink
md: fix problems with freeing private data after ->run failure.
Browse files Browse the repository at this point in the history
If ->run() fails, it can either free the data structures it
allocated, or leave that task to ->free() which will be called
on failures.

However:
  md.c calls ->free() even if ->private_data is NULL, which
     causes problems in some personalities.
  raid0.c frees the data, but doesn't clear ->private_data,
     which will become a problem when we fix md.c

So better fix both these issues at once.

Reported-by: Richard W.M. Jones <rjones@redhat.com>
Fixes: 5aa61f4
URL: https://bugzilla.kernel.org/show_bug.cgi?id=94381
Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
neilbrown committed Mar 20, 2015
1 parent 06e5801 commit 0c35bd4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 2 additions & 1 deletion drivers/md/md.c
Expand Up @@ -5080,7 +5080,8 @@ int md_run(struct mddev *mddev)
}
if (err) {
mddev_detach(mddev);
pers->free(mddev, mddev->private);
if (mddev->private)
pers->free(mddev, mddev->private);
module_put(pers->owner);
bitmap_destroy(mddev);
return err;
Expand Down
2 changes: 0 additions & 2 deletions drivers/md/raid0.c
Expand Up @@ -467,8 +467,6 @@ static int raid0_run(struct mddev *mddev)
dump_zones(mddev);

ret = md_integrity_register(mddev);
if (ret)
raid0_free(mddev, conf);

return ret;
}
Expand Down

0 comments on commit 0c35bd4

Please sign in to comment.