Skip to contentSkip to conversation

target: testing for NULL instead of IS_ERR

PATCH Applied Dan Carpenter 2 participants 2 messages May 19, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target: testing for NULL instead of IS_ERR

core_tpg_alloc_lun() returns ERR_PTRs, it never returns NULL.

Fixes b865ae297e42 ('target: Convert se_portal_group->tpg_lun_list[] to RCU hlist')
drivers/target/target_core_fabric_configfs.c +2 -2
index a0e2946..9be8030 100644
@@ -898,8 +898,8 @@ static struct config_group *target_fabric_make_lun(
 		return ERR_PTR(-EINVAL);
 
 	lun = core_tpg_alloc_lun(se_tpg, unpacked_lun);
-	if (!lun)
-		return ERR_PTR(-ENOMEM);
+	if (IS_ERR(lun))
+		return ERR_CAST(lun);
 
 	lun_cg = &lun->lun_group;
 	lun_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
#1 lore raw
Quoted 11 lines · Dan Carpenter

core_tpg_alloc_lun() returns ERR_PTRs, it never returns NULL.

Fixes b865ae297e42 ('target: Convert se_portal_group->tpg_lun_list[] to RCU hlist')
drivers/target/target_core_fabric_configfs.c +0 -0
index a0e2946..9be8030 100644
@@ -898,8 +898,8 @@ static struct config_group *target_fabric_make_lun(
 		return ERR_PTR(-EINVAL);

drivers/target/target_core_fabric_configfs.c static struct config_group *target_fabric_make_lun(

Quoted 10 lines
drivers/target/target_core_fabric_configfs.c +2 -3
 
 	lun = core_tpg_alloc_lun(se_tpg, unpacked_lun);
-	if (!lun)
-		return ERR_PTR(-ENOMEM);
+	if (IS_ERR(lun))
+		return ERR_CAST(lun);
 
 	lun_cg = &lun->lun_group;
 	lun_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
--

Applied to for-next, and will squash into the original commit soon.

Thanks Dan!

--nab