From e0cf8f045b2023b0b3f919ee93eb94345f648434 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 31 Mar 2009 14:39:39 +1100 Subject: [PATCH] md: md_unregister_thread should cope with being passed NULL 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 --- drivers/md/md.c | 2 ++ drivers/md/raid5.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 117ea5fde56..f30f09cb08e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -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); diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index d019a85547b..81789fa7a02 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -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); -- 2.11.4.GIT