NeilBrown 01f96c0a99 md: Avoid waking up a thread after it has been freed.
Two related problems:

1/ some error paths call "md_unregister_thread(mddev->thread)"
   without subsequently clearing ->thread.  A subsequent call
   to mddev_unlock will try to wake the thread, and crash.

2/ Most calls to md_wakeup_thread are protected against the thread
   disappeared either by:
      - holding the ->mutex
      - having an active request, so something else must be keeping
        the array active.
   However mddev_unlock calls md_wakeup_thread after dropping the
   mutex and without any certainty of an active request, so the
   ->thread could theoretically disappear.
   So we need a spinlock to provide some protections.

So change md_unregister_thread to take a pointer to the thread
pointer, and ensure that it always does the required locking, and
clears the pointer properly.

Reported-by: "Moshe Melnikov" <moshe@zadarastorage.com>
Signed-off-by: NeilBrown <neilb@suse.de>
cc: stable@kernel.org
2011-09-21 15:30:20 +10:00
..
2011-08-05 22:16:42 -04:00
2011-07-26 16:49:47 -07:00
2011-07-28 01:30:07 -07:00
2011-08-11 10:14:18 -07:00
2011-07-22 14:39:51 +09:30
2011-08-13 14:50:32 -04:00
2011-07-26 16:49:47 -07:00
2011-07-25 21:00:19 -07:00
2011-08-03 16:44:21 +02:00
2011-07-26 16:49:47 -07:00
2011-08-16 07:22:16 -07:00
2011-08-07 15:51:45 -07:00
2011-07-26 16:49:47 -07:00
2011-07-26 16:49:47 -07:00
2011-08-16 07:23:34 -07:00