diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-03-05 03:28:24 +0000 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2015-04-09 13:14:19 +0200 |
commit | 033acbf6a597707356691d0621c1496bc5a610b1 (patch) | |
tree | 14bda2b2c4256c98179c8ee484fb08a7edff11cd | |
parent | 64e6cd75c18e03a26efad817ec3ee8c0405c9660 (diff) | |
download | lwn-033acbf6a597707356691d0621c1496bc5a610b1.tar.gz lwn-033acbf6a597707356691d0621c1496bc5a610b1.zip |
target: Fix virtual LUN=0 target_configure_device failure OOPs
commit 5f7da044f8bc1cfb21c962edf34bd5699a76e7ae 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 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>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
-rw-r--r-- | drivers/target/target_core_device.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index c67a56e7ee1c..4711e437479e 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -1492,8 +1492,6 @@ int target_configure_device(struct se_device *dev) ret = dev->transport->configure_device(dev); if (ret) goto out; - dev->dev_flags |= DF_CONFIGURED; - /* * XXX: there is not much point to have two different values here.. */ @@ -1555,6 +1553,8 @@ int target_configure_device(struct se_device *dev) list_add_tail(&dev->g_dev_node, &g_device_list); mutex_unlock(&g_device_mutex); + dev->dev_flags |= DF_CONFIGURED; + return 0; out_free_alua: |