Commit 826376b4 authored by Nicholas Bellinger's avatar Nicholas Bellinger Committed by Kamal Mostafa

target: Fix virtual LUN=0 target_configure_device failure OOPs

commit 5f7da044 upstream.

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 0fd97ccf, go
ahead and move DF_CONFIGURED to end of target_configure_device()
code to handle this special failure case.
Reported-by: default avatarClaudio Fleiner <cmf@daterainc.com>
Cc: Claudio Fleiner <cmf@daterainc.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 935a92e3
...@@ -1499,8 +1499,6 @@ int target_configure_device(struct se_device *dev) ...@@ -1499,8 +1499,6 @@ int target_configure_device(struct se_device *dev)
ret = dev->transport->configure_device(dev); ret = dev->transport->configure_device(dev);
if (ret) if (ret)
goto out; goto out;
dev->dev_flags |= DF_CONFIGURED;
/* /*
* XXX: there is not much point to have two different values here.. * XXX: there is not much point to have two different values here..
*/ */
...@@ -1562,6 +1560,8 @@ int target_configure_device(struct se_device *dev) ...@@ -1562,6 +1560,8 @@ int target_configure_device(struct se_device *dev)
list_add_tail(&dev->g_dev_node, &g_device_list); list_add_tail(&dev->g_dev_node, &g_device_list);
mutex_unlock(&g_device_mutex); mutex_unlock(&g_device_mutex);
dev->dev_flags |= DF_CONFIGURED;
return 0; return 0;
out_free_alua: out_free_alua:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment