History

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.

Nicholas Bellinger committed 11 years ago

Commit 5f7da041 parent 215a8fe1 file · +2 −2Browse files

Unified · Split

drivers/target/target_core_device.c+2−2
@@ -1548,8 +1548,6 @@ int target_configure_device(struct se_device *dev) · 1547 unmodified lines
15481548 ret = dev->transport->configure_device(dev);
15491549 if (ret)
15501550 goto out;
1551− dev->dev_flags |= DF_CONFIGURED;
1552−
15531551 /*
15541552 * XXX: there is not much point to have two different values here..
15551553 */
@@ -1611,6 +1609,8 @@ int target_configure_device(struct se_device *dev) · 55 unmodified lines
16111609 list_add_tail(&dev->g_dev_node, &g_device_list);
16121610 mutex_unlock(&g_device_mutex);
16131611
1612+ dev->dev_flags |= DF_CONFIGURED;
1613+
16141614 return 0;
16151615
16161616 out_free_alua: