iscsi-target: Fix incorrect np->np_thread NULL assignment
authorNicholas Bellinger <nab@linux-iscsi.org>
Wed, 11 Dec 2013 23:45:32 +0000 (15:45 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2014 20:25:09 +0000 (12:25 -0800)
commitf0c626f9e435d788e9b8950be22a0b801ec5e5ba
tree62e7d07760879842fc5043b2aa85ca9c8eabe631
parent253c3ef7e8f3e353b584f783cae2e4d527aaac70
iscsi-target: Fix incorrect np->np_thread NULL assignment

commit db6077fd0b7dd41dc6ff18329cec979379071f87 upstream.

When shutting down a target there is a race condition between
iscsit_del_np() and __iscsi_target_login_thread().
The latter sets the thread pointer to NULL, and the former
tries to issue kthread_stop() on that pointer without any
synchronization.

This patch moves the np->np_thread NULL assignment into
iscsit_del_np(), after kthread_stop() has completed. It also
removes the signal_pending() + np_state check, and only
exits when kthread_should_stop() is true.

Reported-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/iscsi/iscsi_target.c
drivers/target/iscsi/iscsi_target_login.c