target/configfs: Remove unnecessary null test
Subsystems (2)
PATCH 1/1 target/configfs: Remove unnecessary null test
This patch removes the null test on lun_cg. lun_cg is initialized at the beginning of the function to &lun->lun_group. Since lun_cg is dereferenced prior to the null test, it must be a valid pointer.
The following Coccinelle script is used for detecting the change:
@r@
expression e,f;
identifier g,y;
statement S1,S2;
@@
*e = &f->g
<+...
f->y
...+>
*if (e != NULL || ...)
S1 else S2
--- drivers/target/target_core_fabric_configfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/target/target_core_fabric_configfs.c +1 -2
@@ -917,8 +917,7 @@ static struct config_group *target_fabric_make_lun(return &lun->lun_group; out: -if (lun_cg) -kfree (lun_cg->default_groups); +kfree (lun_cg->default_groups);return ERR_PTR (errno); }
Signature · 1 line
1.9.1
Nicholas A. Bellinger
AppliedHi Himangi,
Quoted 30 lines · Himangi Saraogi
This patch removes the null test on
lun_cg.lun_cgis initialized at the beginning of the function to&lun->lun_group. Sincelun_cgis dereferenced prior to the null test, it must be a valid pointer.The following Coccinelle script is used for detecting the change:
@r@
expression e,f;
identifier g,y;
statement S1,S2;
@@*e =
&f->g
<+...
f->y
...+>
*if (e != NULL || ...)
S1 else S2Signed-off-by Himangi Saraogi <[email protected]>Acked-by Julia Lawall <[email protected]>--- drivers/target/target_core_fabric_configfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/target/target_core_fabric_configfs.c +0
-0
drivers/target/target_core_fabric_configfs.c static struct config_group *target_fabric_make_lun( · line 923
Quoted 9 lines
drivers/target/target_core_fabric_configfs.c +1
-2@@ -917,8 +917,7 @@ static struct config_group *target_fabric_make_lun(return &lun->lun_group; out: -if (lun_cg) -kfree (lun_cg->default_groups); +kfree (lun_cg->default_groups);return ERR_PTR (errno); }
Thanks, applied to target-pending/for-next.
--nab