linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/configfs: Remove unnecessary null test
@ 2014-07-16 20:59 Himangi Saraogi
  2014-07-30  1:23 ` Nicholas A. Bellinger
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-07-16 20:59 UTC (permalink / raw)
  To: Nicholas A. Bellinger, linux-scsi, target-devel, linux-kernel
  Cc: julia.lawall

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

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 drivers/target/target_core_fabric_configfs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
index 7de9f04..7228a18 100644
--- a/drivers/target/target_core_fabric_configfs.c
+++ b/drivers/target/target_core_fabric_configfs.c
@@ -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);
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] target/configfs: Remove unnecessary null test
  2014-07-16 20:59 [PATCH] target/configfs: Remove unnecessary null test Himangi Saraogi
@ 2014-07-30  1:23 ` Nicholas A. Bellinger
  0 siblings, 0 replies; 2+ messages in thread
From: Nicholas A. Bellinger @ 2014-07-30  1:23 UTC (permalink / raw)
  To: Himangi Saraogi; +Cc: linux-scsi, target-devel, linux-kernel, julia.lawall

Hi Himangi,

On Thu, 2014-07-17 at 02:29 +0530, Himangi Saraogi wrote:
> 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
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
>  drivers/target/target_core_fabric_configfs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/target/target_core_fabric_configfs.c b/drivers/target/target_core_fabric_configfs.c
> index 7de9f04..7228a18 100644
> --- a/drivers/target/target_core_fabric_configfs.c
> +++ b/drivers/target/target_core_fabric_configfs.c
> @@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-30  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-16 20:59 [PATCH] target/configfs: Remove unnecessary null test Himangi Saraogi
2014-07-30  1:23 ` Nicholas A. Bellinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).