Skip to content

Commit

Permalink
md: md_unregister_thread should cope with being passed NULL
Browse files Browse the repository at this point in the history
Mostly md_unregister_thread is only called when we know that the
thread is NULL, but sometimes we need to check first.  It is safer
to put the check inside md_unregister_thread itself.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Mar 31, 2009
1 parent 91adb56 commit e0cf8f0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -5382,6 +5382,8 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,

void md_unregister_thread(mdk_thread_t *thread)
{
if (!thread)
return;
dprintk("interrupting MD-thread pid %d\n", task_pid_nr(thread->tsk));

kthread_stop(thread->tsk);
Expand Down
3 changes: 1 addition & 2 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -4463,8 +4463,7 @@ static int run(mddev_t *mddev)

return 0;
abort:
if (mddev->thread)
md_unregister_thread(mddev->thread);
md_unregister_thread(mddev->thread);
mddev->thread = NULL;
if (conf) {
shrink_stripes(conf);
Expand Down

0 comments on commit e0cf8f0

Please sign in to comment.