target: Fix virtual LUN=0 target_configure_device failure OOPs
authorNicholas Bellinger <nab@linux-iscsi.org>
Thu, 5 Mar 2015 03:28:24 +0000 (03:28 +0000)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 20 Mar 2015 06:26:44 +0000 (23:26 -0700)
commit5f7da044f8bc1cfb21c962edf34bd5699a76e7ae
treedfc0f05b41de7359dd2d6099a498b91a8f3334d5
parent215a8fe4198f607f34ecdbc9969dae783d8b5a61
target: Fix virtual LUN=0 target_configure_device failure OOPs

This patch fixes a NULL pointer dereference triggered by a late
target_configure_device() -> alloc_workqueue() failure that results
in target_free_device() being called with DF_CONFIGURED already set,
which subsequently OOPses in destroy_workqueue() code.

Currently this only happens at modprobe target_core_mod time when
core_dev_setup_virtual_lun0() -> target_configure_device() fails,
and the explicit target_free_device() gets called.

To address this bug originally introduced by commit 0fd97ccf45, go
ahead and move DF_CONFIGURED to end of target_configure_device()
code to handle this special failure case.

Reported-by: Claudio Fleiner <cmf@daterainc.com>
Cc: Claudio Fleiner <cmf@daterainc.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: <stable@vger.kernel.org> # v3.7+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_device.c