aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-01-11 15:43:38 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2012-01-18 03:33:44 -0500
commit8d9efe539cf78f6a90947d47100e4a86d907750f (patch)
tree82c9981047853687f83117d65de94ba18a25f144
parent1dd0a0674530da61cdbfadd88c96949b483a7c19 (diff)
target: fix return code of core_tpg_.*_lun
- core_tpg_pre_addlun() returns always ERR_PTR() or the pointer, never NULL. The additional check for NULL in core_dev_add_lun() is not required. - core_tpg_pre_dellun() returns always ERR_PTR() or the pointer, never NULL. The check for NULL in core_dev_del_lun() is wrong. The third argument (int *) is never used, remove it. - core_dev_add_lun() returns always NULL or the pointer, never ERR_PTR. The check for IS_ERR() is not required. (nab: Convert core_dev_add_lun() use err.h macros for failure handling to be consistent with the rest of target_core_fabric_configfs.c callers) Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: <stable@vger.kernel.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/target_core_device.c19
-rw-r--r--drivers/target/target_core_fabric_configfs.c4
-rw-r--r--drivers/target/target_core_internal.h2
-rw-r--r--drivers/target/target_core_tpg.c3
4 files changed, 14 insertions, 14 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 00159a4e781f..de5f4fea7f62 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1295,24 +1295,26 @@ struct se_lun *core_dev_add_lun(
1295{ 1295{
1296 struct se_lun *lun_p; 1296 struct se_lun *lun_p;
1297 u32 lun_access = 0; 1297 u32 lun_access = 0;
1298 int rc;
1298 1299
1299 if (atomic_read(&dev->dev_access_obj.obj_access_count) != 0) { 1300 if (atomic_read(&dev->dev_access_obj.obj_access_count) != 0) {
1300 pr_err("Unable to export struct se_device while dev_access_obj: %d\n", 1301 pr_err("Unable to export struct se_device while dev_access_obj: %d\n",
1301 atomic_read(&dev->dev_access_obj.obj_access_count)); 1302 atomic_read(&dev->dev_access_obj.obj_access_count));
1302 return NULL; 1303 return ERR_PTR(-EACCES);
1303 } 1304 }
1304 1305
1305 lun_p = core_tpg_pre_addlun(tpg, lun); 1306 lun_p = core_tpg_pre_addlun(tpg, lun);
1306 if ((IS_ERR(lun_p)) || !lun_p) 1307 if (IS_ERR(lun_p))
1307 return NULL; 1308 return lun_p;
1308 1309
1309 if (dev->dev_flags & DF_READ_ONLY) 1310 if (dev->dev_flags & DF_READ_ONLY)
1310 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY; 1311 lun_access = TRANSPORT_LUNFLAGS_READ_ONLY;
1311 else 1312 else
1312 lun_access = TRANSPORT_LUNFLAGS_READ_WRITE; 1313 lun_access = TRANSPORT_LUNFLAGS_READ_WRITE;
1313 1314
1314 if (core_tpg_post_addlun(tpg, lun_p, lun_access, dev) < 0) 1315 rc = core_tpg_post_addlun(tpg, lun_p, lun_access, dev);
1315 return NULL; 1316 if (rc < 0)
1317 return ERR_PTR(rc);
1316 1318
1317 pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from" 1319 pr_debug("%s_TPG[%u]_LUN[%u] - Activated %s Logical Unit from"
1318 " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(), 1320 " CORE HBA: %u\n", tpg->se_tpg_tfo->get_fabric_name(),
@@ -1349,11 +1351,10 @@ int core_dev_del_lun(
1349 u32 unpacked_lun) 1351 u32 unpacked_lun)
1350{ 1352{
1351 struct se_lun *lun; 1353 struct se_lun *lun;
1352 int ret = 0;
1353 1354
1354 lun = core_tpg_pre_dellun(tpg, unpacked_lun, &ret); 1355 lun = core_tpg_pre_dellun(tpg, unpacked_lun);
1355 if (!lun) 1356 if (IS_ERR(lun))
1356 return ret; 1357 return PTR_ERR(lun);
1357 1358
1358 core_tpg_post_dellun(tpg, lun); 1359 core_tpg_post_dellun(tpg, lun);
1359 1360
diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 4f77cce22646..9a2ce11e1a6e 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -766,9 +766,9 @@ static int target_fabric_port_link(
766 766
767 lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev, 767 lun_p = core_dev_add_lun(se_tpg, dev->se_hba, dev,
768 lun->unpacked_lun); 768 lun->unpacked_lun);
769 if (IS_ERR(lun_p) || !lun_p) { 769 if (IS_ERR(lun_p)) {
770 pr_err("core_dev_add_lun() failed\n"); 770 pr_err("core_dev_add_lun() failed\n");
771 ret = -EINVAL; 771 ret = PTR_ERR(lun_p);
772 goto out; 772 goto out;
773 } 773 }
774 774
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 26f135e94f6e..45001364788a 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -90,7 +90,7 @@ void core_tpg_wait_for_nacl_pr_ref(struct se_node_acl *);
90struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32); 90struct se_lun *core_tpg_pre_addlun(struct se_portal_group *, u32);
91int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *, 91int core_tpg_post_addlun(struct se_portal_group *, struct se_lun *,
92 u32, void *); 92 u32, void *);
93struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32, int *); 93struct se_lun *core_tpg_pre_dellun(struct se_portal_group *, u32 unpacked_lun);
94int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *); 94int core_tpg_post_dellun(struct se_portal_group *, struct se_lun *);
95 95
96/* target_core_transport.c */ 96/* target_core_transport.c */
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index b7668029bb31..06336ecd872d 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -807,8 +807,7 @@ static void core_tpg_shutdown_lun(
807 807
808struct se_lun *core_tpg_pre_dellun( 808struct se_lun *core_tpg_pre_dellun(
809 struct se_portal_group *tpg, 809 struct se_portal_group *tpg,
810 u32 unpacked_lun, 810 u32 unpacked_lun)
811 int *ret)
812{ 811{
813 struct se_lun *lun; 812 struct se_lun *lun;
814 813