]> git.baikalelectronics.ru Git - kernel.git/commit
md: protect against NULL reference when waiting to start a raid10.
authorNeilBrown <neilb@suse.de>
Thu, 9 Dec 2010 06:02:14 +0000 (17:02 +1100)
committerNeilBrown <neilb@suse.de>
Thu, 9 Dec 2010 06:02:14 +0000 (17:02 +1100)
commit294097819fd47472bbb4d8d6b14156655652f81b
tree9de6f6b4f9244802ccf77312f7fba8612dd13a75
parent901c5039fb75070995fdd9bb51ca20753dc4cd67
md: protect against NULL reference when waiting to start a raid10.

When we fail to start a raid10 for some reason, we call
md_unregister_thread to kill the thread that was created.

Unfortunately md_thread() will then make one call into the handler
(raid10d) even though md_wakeup_thread has not been called.  This is
not safe and as md_unregister_thread is called after mddev->private
has been set to NULL, it will definitely cause a NULL dereference.

So fix this at both ends:
 - md_thread should only call the handler if THREAD_WAKEUP has been
   set.
 - raid10 should call md_unregister_thread before setting things
   to NULL just like all the other raid modules do.

This is applicable to 2.6.35 and later.

Cc: stable@kernel.org
Reported-by: "Citizen" <citizen_lee@thecus.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/md.c
drivers/md/raid10.c