Skip to content

Commit b54521a

Browse files
Nicholas Bellingersashalevin
authored andcommitted
target: Fix virtual LUN=0 target_configure_device failure OOPs
[ Upstream commit 5f7da04 ] 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 0fd97cc, 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> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 6526d32 commit b54521a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/target/target_core_device.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,8 +1598,6 @@ int target_configure_device(struct se_device *dev)
15981598
ret = dev->transport->configure_device(dev);
15991599
if (ret)
16001600
goto out;
1601-
dev->dev_flags |= DF_CONFIGURED;
1602-
16031601
/*
16041602
* XXX: there is not much point to have two different values here..
16051603
*/
@@ -1661,6 +1659,8 @@ int target_configure_device(struct se_device *dev)
16611659
list_add_tail(&dev->g_dev_node, &g_device_list);
16621660
mutex_unlock(&g_device_mutex);
16631661

1662+
dev->dev_flags |= DF_CONFIGURED;
1663+
16641664
return 0;
16651665

16661666
out_free_alua:

0 commit comments

Comments
 (0)