target: fix regression with dev_link_magic in target_fabric_port_link
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 25 Jan 2013 02:57:14 +0000 (21:57 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Feb 2013 00:27:07 +0000 (18:27 -0600)
This is to fix a regression that only affect the stable (not for the mainline)
that the stable commit fdf9d86 was incorrectly placed dev->dev_link_magic check
before the *dev assignment in target_fabric_port_link() due to fuzzy automatically
context adjustment during the back-porting.

Reported-by: Chris Boot <bootc@bootc.net>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: CAI Qian <caiqian@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_fabric_configfs.c

index a55f91aca7610c373d25face70d109d120a581b7..9430cd2833e79fc738b07c55807e627578644440 100644 (file)
@@ -751,12 +751,6 @@ static int target_fabric_port_link(
        struct target_fabric_configfs *tf;
        int ret;
 
-       if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) {
-               pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:"
-                       " %p to struct se_device: %p\n", se_dev_ci, dev);
-               return -EFAULT;
-       }
-
        tpg_ci = &lun_ci->ci_parent->ci_group->cg_item;
        se_tpg = container_of(to_config_group(tpg_ci),
                                struct se_portal_group, tpg_group);
@@ -774,6 +768,11 @@ static int target_fabric_port_link(
                ret = -ENODEV;
                goto out;
        }
+       if (dev->dev_link_magic != SE_DEV_LINK_MAGIC) {
+               pr_err("Bad dev->dev_link_magic, not a valid se_dev_ci pointer:"
+                       " %p to struct se_device: %p\n", se_dev_ci, dev);
+               return -EFAULT;
+       }
 
        lun_p = core_dev_add_lun(se_tpg, dev, lun->unpacked_lun);
        if (IS_ERR(lun_p)) {