netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
@ 2014-11-18 19:16                                   ` SF Markus Elfring
  2014-11-19 20:20                                     ` David Miller
  2014-11-18 19:47                                   ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                     ` (53 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:16 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:10:34 +0100

The proc_remove() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/core/pktgen.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8b849dd..35046a8 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3698,8 +3698,7 @@ static int pktgen_remove_device(struct pktgen_thread *t,
 	/* Remove proc before if_list entry, because add_device uses
 	 * list to determine if interface already exist, avoid race
 	 * with proc_create_data() */
-	if (pkt_dev->entry)
-		proc_remove(pkt_dev->entry);
+	proc_remove(pkt_dev->entry);
 
 	/* And update the thread if_list */
 	_rem_dev_from_if_list(t, pkt_dev);
-- 
2.1.3

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

* [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
  2014-11-18 19:16                                   ` [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove" SF Markus Elfring
@ 2014-11-18 19:47                                   ` SF Markus Elfring
  2014-11-19 13:40                                     ` Pablo Neira Ayuso
  2014-11-19 22:26                                     ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls Julian Anastasov
  2014-11-18 20:08                                   ` [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get" SF Markus Elfring
                                                     ` (52 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-18 19:47 UTC (permalink / raw)
  To: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Pablo Neira Ayuso, Patrick McHardy, Simon Horman, Wensong Zhang,
	netdev, lvs-devel, netfilter-devel, coreteam
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:37:05 +0100

The functions free_percpu() and module_put() test whether their argument
is NULL and then return immediately. Thus the test around the call is
not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
 net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
 net/netfilter/ipvs/ip_vs_sched.c | 3 +--
 net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
 net/netfilter/nf_tables_api.c    | 3 +--
 5 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index fd3f444..7c5e40a 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
 
 static void ip_vs_service_free(struct ip_vs_service *svc)
 {
-	if (svc->stats.cpustats)
-		free_percpu(svc->stats.cpustats);
+	free_percpu(svc->stats.cpustats);
 	kfree(svc);
 }
 
diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
index 1a82b29..0df17ca 100644
--- a/net/netfilter/ipvs/ip_vs_pe.c
+++ b/net/netfilter/ipvs/ip_vs_pe.c
@@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
 			rcu_read_unlock();
 			return pe;
 		}
-		if (pe->module)
-			module_put(pe->module);
+		module_put(pe->module);
 	}
 	rcu_read_unlock();
 
diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 4dbcda6..199760c 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
 			mutex_unlock(&ip_vs_sched_mutex);
 			return sched;
 		}
-		if (sched->module)
-			module_put(sched->module);
+		module_put(sched->module);
 	}
 
 	mutex_unlock(&ip_vs_sched_mutex);
diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
index eadffb2..cafe28d 100644
--- a/net/netfilter/ipvs/ip_vs_sync.c
+++ b/net/netfilter/ipvs/ip_vs_sync.c
@@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
 
 		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
 		if (!p->pe_data) {
-			if (p->pe->module)
-				module_put(p->pe->module);
+			module_put(p->pe->module);
 			return -ENOMEM;
 		}
 		p->pe_data_len = pe_data_len;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index deeb95f..b115f54 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
 			break;
 		case NFT_MSG_NEWCHAIN:
 			if (nft_trans_chain_update(trans)) {
-				if (nft_trans_chain_stats(trans))
-					free_percpu(nft_trans_chain_stats(trans));
+				free_percpu(nft_trans_chain_stats(trans));
 
 				nft_trans_destroy(trans);
 			} else {
-- 
2.1.3


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

* [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
  2014-11-18 19:16                                   ` [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove" SF Markus Elfring
  2014-11-18 19:47                                   ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-18 20:08                                   ` SF Markus Elfring
  2014-11-19 20:28                                     ` David Miller
  2014-11-18 20:26                                   ` [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
                                                     ` (51 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:08 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:03:13 +0100

The __module_get() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72d..0317b91 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -142,8 +142,7 @@ int netlink_add_tap(struct netlink_tap *nt)
 	list_add_rcu(&nt->list, &netlink_tap_all);
 	spin_unlock(&netlink_tap_lock);
 
-	if (nt->module)
-		__module_get(nt->module);
+	__module_get(nt->module);
 
 	return 0;
 }
-- 
2.1.3

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

* [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (2 preceding siblings ...)
  2014-11-18 20:08                                   ` [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get" SF Markus Elfring
@ 2014-11-18 20:26                                   ` SF Markus Elfring
  2014-11-19 16:47                                     ` John Fastabend
  2014-11-18 20:45                                   ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms" SF Markus Elfring
                                                     ` (50 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:26 UTC (permalink / raw)
  To: David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:21:16 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sched/cls_bpf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 0e30d58..f323944 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
 
 	if (fp_old)
 		bpf_prog_destroy(fp_old);
-	if (bpf_old)
-		kfree(bpf_old);
+	kfree(bpf_old);
 
 	return 0;
 
-- 
2.1.3

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

* [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (3 preceding siblings ...)
  2014-11-18 20:26                                   ` [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2014-11-18 20:45                                   ` SF Markus Elfring
  2014-11-19  8:45                                     ` Dan Carpenter
  2014-11-19 19:55                                   ` [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
                                                     ` (49 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-18 20:45 UTC (permalink / raw)
  To: David S. Miller, Herbert Xu, Steffen Klassert, netdev
  Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:41:26 +0100

The ipcomp_free_tfms() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/xfrm/xfrm_ipcomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index ccfdc71..47863cd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -320,8 +320,7 @@ error:
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
 {
-	if (ipcd->tfms)
-		ipcomp_free_tfms(ipcd->tfms);
+	ipcomp_free_tfms(ipcd->tfms);
 	ipcomp_free_scratches();
 }
 
-- 
2.1.3

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

* Re: [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-18 20:45                                   ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms" SF Markus Elfring
@ 2014-11-19  8:45                                     ` Dan Carpenter
  2014-11-19  9:51                                       ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Dan Carpenter @ 2014-11-19  8:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Coccinelle

On Tue, Nov 18, 2014 at 09:45:41PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:41:26 +0100
> 
> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 

It doesn't though...

regards,
dan carpenter

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19  8:45                                     ` Dan Carpenter
@ 2014-11-19  9:51                                       ` SF Markus Elfring
  2014-11-19  9:58                                         ` Julia Lawall
  2014-11-19 10:10                                         ` Dan Carpenter
  0 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-19  9:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Julia Lawall

>> The ipcomp_free_tfms() function tests whether its argument is NULL and then
>> returns immediately. Thus the test around the call is not needed.
> 
> It doesn't though...

You are right that this function implementation does a bit more before
returning because of a detected null pointer.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id=394efd19d5fcae936261bd48e5b33b21897aacf8#n247

Can you agree that input parameter validation is also performed there?
Do you want that I resend my patch with a corrected commit message?

Regards,
Markus

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19  9:51                                       ` SF Markus Elfring
@ 2014-11-19  9:58                                         ` Julia Lawall
  2014-11-19 10:10                                         ` Dan Carpenter
  1 sibling, 0 replies; 273+ messages in thread
From: Julia Lawall @ 2014-11-19  9:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, David S. Miller, Herbert Xu, Steffen Klassert,
	netdev, LKML, kernel-janitors



On Wed, 19 Nov 2014, SF Markus Elfring wrote:

> >> The ipcomp_free_tfms() function tests whether its argument is NULL and then
> >> returns immediately. Thus the test around the call is not needed.
> >
> > It doesn't though...
>
> You are right that this function implementation does a bit more before
> returning because of a detected null pointer.
> https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/net/xfrm/xfrm_ipcomp.c?id=394efd19d5fcae936261bd48e5b33b21897aacf8#n247
>
> Can you agree that input parameter validation is also performed there?
> Do you want that I resend my patch with a corrected commit message?

This is completely crazy.  The function performs a side effect on a data
structure.  If the call site doesn't want that done in a certain case,
then it should not be done.

julia

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19  9:51                                       ` SF Markus Elfring
  2014-11-19  9:58                                         ` Julia Lawall
@ 2014-11-19 10:10                                         ` Dan Carpenter
  2014-11-19 18:19                                           ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: Dan Carpenter @ 2014-11-19 10:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Herbert Xu, Steffen Klassert, netdev, LKML,
	kernel-janitors, Julia Lawall

I have come to view you as a very clever troll.  You will say
infuriating things like "That is an interesting background information
but the function implementation update suggestion is correct" and
pretend to not see the bug for nine emails.  Then you'll say something
"Ha ha, I audited all the call trees and it can't actually be NULL so
you were getting angry for no reason."  Except you'll say it in a
more obfuscated way than that.  This is what you did last time.

regards,
dan carpenter

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-18 19:47                                   ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-19 13:40                                     ` Pablo Neira Ayuso
  2015-07-02 15:10                                       ` [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
  2014-11-19 22:26                                     ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls Julian Anastasov
  1 sibling, 1 reply; 273+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-19 13:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Patrick McHardy, Simon Horman, Wensong Zhang, netdev, lvs-devel,
	netfilter-devel, coreteam, LKML, kernel-janitors, Coccinelle

On Tue, Nov 18, 2014 at 08:47:31PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:37:05 +0100
> 
> The functions free_percpu() and module_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call is
> not needed.

@IPVS folks: Since this involves a nf_tables specific chunk, ack your
chunks and I'll put this into nf-next to speed up things.

Thanks.

> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
>  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
>  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
>  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
>  net/netfilter/nf_tables_api.c    | 3 +--
>  5 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index fd3f444..7c5e40a 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
>  
>  static void ip_vs_service_free(struct ip_vs_service *svc)
>  {
> -	if (svc->stats.cpustats)
> -		free_percpu(svc->stats.cpustats);
> +	free_percpu(svc->stats.cpustats);
>  	kfree(svc);
>  }
>  
> diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> index 1a82b29..0df17ca 100644
> --- a/net/netfilter/ipvs/ip_vs_pe.c
> +++ b/net/netfilter/ipvs/ip_vs_pe.c
> @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
>  			rcu_read_unlock();
>  			return pe;
>  		}
> -		if (pe->module)
> -			module_put(pe->module);
> +		module_put(pe->module);
>  	}
>  	rcu_read_unlock();
>  
> diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> index 4dbcda6..199760c 100644
> --- a/net/netfilter/ipvs/ip_vs_sched.c
> +++ b/net/netfilter/ipvs/ip_vs_sched.c
> @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
>  			mutex_unlock(&ip_vs_sched_mutex);
>  			return sched;
>  		}
> -		if (sched->module)
> -			module_put(sched->module);
> +		module_put(sched->module);
>  	}
>  
>  	mutex_unlock(&ip_vs_sched_mutex);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index eadffb2..cafe28d 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
>  
>  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
>  		if (!p->pe_data) {
> -			if (p->pe->module)
> -				module_put(p->pe->module);
> +			module_put(p->pe->module);
>  			return -ENOMEM;
>  		}
>  		p->pe_data_len = pe_data_len;
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index deeb95f..b115f54 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
>  			break;
>  		case NFT_MSG_NEWCHAIN:
>  			if (nft_trans_chain_update(trans)) {
> -				if (nft_trans_chain_stats(trans))
> -					free_percpu(nft_trans_chain_stats(trans));
> +				free_percpu(nft_trans_chain_stats(trans));
>  
>  				nft_trans_destroy(trans);
>  			} else {
> -- 
> 2.1.3
> 

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-18 20:26                                   ` [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2014-11-19 16:47                                     ` John Fastabend
  2014-11-19 17:00                                       ` Daniel Borkmann
  2014-11-19 18:49                                       ` SF Markus Elfring
  0 siblings, 2 replies; 273+ messages in thread
From: John Fastabend @ 2014-11-19 16:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors,
	Coccinelle

On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:21:16 +0100
>
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   net/sched/cls_bpf.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index 0e30d58..f323944 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -212,8 +212,7 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
>
>   	if (fp_old)
>   		bpf_prog_destroy(fp_old);
> -	if (bpf_old)
> -		kfree(bpf_old);
> +	kfree(bpf_old);
>
>   	return 0;
>
>

Maybe I need some coffee but I can't figure out what this
patch is against...

# grep bpf_old ./net/sched/cls_bpf.c
#

Marcus, what tree are you looking at?

-- 
John Fastabend         Intel Corporation

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

* Re: [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 16:47                                     ` John Fastabend
@ 2014-11-19 17:00                                       ` Daniel Borkmann
  2014-11-19 18:49                                       ` SF Markus Elfring
  1 sibling, 0 replies; 273+ messages in thread
From: Daniel Borkmann @ 2014-11-19 17:00 UTC (permalink / raw)
  To: John Fastabend
  Cc: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev,
	LKML, kernel-janitors, Coccinelle

On 11/19/2014 05:47 PM, John Fastabend wrote:
> On 11/18/2014 12:26 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
...
>>       if (fp_old)
>>           bpf_prog_destroy(fp_old);
>> -    if (bpf_old)
>> -        kfree(bpf_old);
>> +    kfree(bpf_old);
>>
>>       return 0;
>>
>
> Maybe I need some coffee but I can't figure out what this
> patch is against...
>
> # grep bpf_old ./net/sched/cls_bpf.c
> #

Coffee is always good. :)

Yeah, you actually removed this in commit 1f947bf151e90ec ("net:
sched: rcu'ify cls_bpf"), so looks like Markus's tree is not
up to date ...

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

* Re: net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms"
  2014-11-19 10:10                                         ` Dan Carpenter
@ 2014-11-19 18:19                                           ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-19 18:19 UTC (permalink / raw)
  To: dan.carpenter
  Cc: elfring, herbert, steffen.klassert, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 19 Nov 2014 13:10:03 +0300

> I have come to view you as a very clever troll.

+1

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 16:47                                     ` John Fastabend
  2014-11-19 17:00                                       ` Daniel Borkmann
@ 2014-11-19 18:49                                       ` SF Markus Elfring
  2014-11-19 19:09                                         ` Daniel Borkmann
  2014-11-20  8:47                                         ` Julia Lawall
  1 sibling, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-19 18:49 UTC (permalink / raw)
  To: John Fastabend
  Cc: David S. Miller, Jamal Hadi Salim, netdev, LKML, kernel-janitors

> Marcus, what tree are you looking at?

I dared to base this update suggestion on the source files
for Linux 3.17.3. Are newer software developments relevant here?

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Regards,
Markus

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 18:49                                       ` SF Markus Elfring
@ 2014-11-19 19:09                                         ` Daniel Borkmann
  2014-11-20  8:47                                         ` Julia Lawall
  1 sibling, 0 replies; 273+ messages in thread
From: Daniel Borkmann @ 2014-11-19 19:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On 11/19/2014 07:49 PM, SF Markus Elfring wrote:
>> Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?
>
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/

Pointing to linux-next and saying you based your changes on 3.17.3
is confusing, please look correctly when you provide a link ...

Again, John's commit 1f947bf151e90ec0b removed the relevant part in
cls_bpf_modify_existing() that you're trying to modify:

$ git grep -n bpf_old net/sched/cls_bpf.c
$

Therefore, this patch is not needed.

Thanks !

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

* [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (4 preceding siblings ...)
  2014-11-18 20:45                                   ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms" SF Markus Elfring
@ 2014-11-19 19:55                                   ` SF Markus Elfring
  2014-11-19 21:54                                     ` David Miller
  2014-11-20 13:28                                   ` [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put" SF Markus Elfring
                                                     ` (48 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-19 19:55 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:48:26 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/isdn/mISDN/l1oip_codec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
index a601c84..9b033be 100644
--- a/drivers/isdn/mISDN/l1oip_codec.c
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -312,10 +312,8 @@ l1oip_ulaw_to_alaw(u8 *data, int len, u8 *result)
 void
 l1oip_4bit_free(void)
 {
-	if (table_dec)
-		vfree(table_dec);
-	if (table_com)
-		vfree(table_com);
+	vfree(table_dec);
+	vfree(table_com);
 	table_com = NULL;
 	table_dec = NULL;
 }
-- 
2.1.3

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

* Re: [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove"
  2014-11-18 19:16                                   ` [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove" SF Markus Elfring
@ 2014-11-19 20:20                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-19 20:20 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 20:16:05 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:10:34 +0100
> 
> The proc_remove() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get"
  2014-11-18 20:08                                   ` [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get" SF Markus Elfring
@ 2014-11-19 20:28                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-19 20:28 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 18 Nov 2014 21:08:39 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 21:03:13 +0100
> 
> The __module_get() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree"
  2014-11-19 19:55                                   ` [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2014-11-19 21:54                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-19 21:54 UTC (permalink / raw)
  To: elfring; +Cc: isdn, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 20:55:18 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 20:48:26 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-18 19:47                                   ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls SF Markus Elfring
  2014-11-19 13:40                                     ` Pablo Neira Ayuso
@ 2014-11-19 22:26                                     ` Julian Anastasov
  2014-11-20  1:13                                       ` Simon Horman
  1 sibling, 1 reply; 273+ messages in thread
From: Julian Anastasov @ 2014-11-19 22:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Patrick McHardy, Simon Horman, Wensong Zhang, netdev, lvs-devel,
	netfilter-devel, coreteam, LKML, kernel-janitors, Coccinelle


	Hello,

On Tue, 18 Nov 2014, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 18 Nov 2014 20:37:05 +0100
> 
> The functions free_percpu() and module_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call is
> not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

	Pablo, the IPVS parts look ok to me,

Acked-by: Julian Anastasov <ja@ssi.bg>

> ---
>  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
>  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
>  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
>  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
>  net/netfilter/nf_tables_api.c    | 3 +--
>  5 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> index fd3f444..7c5e40a 100644
> --- a/net/netfilter/ipvs/ip_vs_ctl.c
> +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
>  
>  static void ip_vs_service_free(struct ip_vs_service *svc)
>  {
> -	if (svc->stats.cpustats)
> -		free_percpu(svc->stats.cpustats);
> +	free_percpu(svc->stats.cpustats);
>  	kfree(svc);
>  }
>  
> diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> index 1a82b29..0df17ca 100644
> --- a/net/netfilter/ipvs/ip_vs_pe.c
> +++ b/net/netfilter/ipvs/ip_vs_pe.c
> @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
>  			rcu_read_unlock();
>  			return pe;
>  		}
> -		if (pe->module)
> -			module_put(pe->module);
> +		module_put(pe->module);
>  	}
>  	rcu_read_unlock();
>  
> diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> index 4dbcda6..199760c 100644
> --- a/net/netfilter/ipvs/ip_vs_sched.c
> +++ b/net/netfilter/ipvs/ip_vs_sched.c
> @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
>  			mutex_unlock(&ip_vs_sched_mutex);
>  			return sched;
>  		}
> -		if (sched->module)
> -			module_put(sched->module);
> +		module_put(sched->module);
>  	}
>  
>  	mutex_unlock(&ip_vs_sched_mutex);
> diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> index eadffb2..cafe28d 100644
> --- a/net/netfilter/ipvs/ip_vs_sync.c
> +++ b/net/netfilter/ipvs/ip_vs_sync.c
> @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
>  
>  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
>  		if (!p->pe_data) {
> -			if (p->pe->module)
> -				module_put(p->pe->module);
> +			module_put(p->pe->module);
>  			return -ENOMEM;
>  		}
>  		p->pe_data_len = pe_data_len;
> diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> index deeb95f..b115f54 100644
> --- a/net/netfilter/nf_tables_api.c
> +++ b/net/netfilter/nf_tables_api.c
> @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
>  			break;
>  		case NFT_MSG_NEWCHAIN:
>  			if (nft_trans_chain_update(trans)) {
> -				if (nft_trans_chain_stats(trans))
> -					free_percpu(nft_trans_chain_stats(trans));
> +				free_percpu(nft_trans_chain_stats(trans));
>  
>  				nft_trans_destroy(trans);
>  			} else {
> -- 
> 2.1.3

Regards

--
Julian Anastasov <ja@ssi.bg>

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-19 22:26                                     ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls Julian Anastasov
@ 2014-11-20  1:13                                       ` Simon Horman
  2014-11-20 12:16                                         ` Pablo Neira Ayuso
  0 siblings, 1 reply; 273+ messages in thread
From: Simon Horman @ 2014-11-20  1:13 UTC (permalink / raw)
  To: Julian Anastasov
  Cc: SF Markus Elfring, David S. Miller, Jozsef Kadlecsik,
	Pablo Neira Ayuso, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Coccinelle

On Thu, Nov 20, 2014 at 12:26:56AM +0200, Julian Anastasov wrote:
> 
> 	Hello,
> 
> On Tue, 18 Nov 2014, SF Markus Elfring wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 18 Nov 2014 20:37:05 +0100
> > 
> > The functions free_percpu() and module_put() test whether their argument
> > is NULL and then return immediately. Thus the test around the call is
> > not needed.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> 	Pablo, the IPVS parts look ok to me,
> 
> Acked-by: Julian Anastasov <ja@ssi.bg>

Acked-by: Simon Horman <horms@verge.net.au>

> 
> > ---
> >  net/netfilter/ipvs/ip_vs_ctl.c   | 3 +--
> >  net/netfilter/ipvs/ip_vs_pe.c    | 3 +--
> >  net/netfilter/ipvs/ip_vs_sched.c | 3 +--
> >  net/netfilter/ipvs/ip_vs_sync.c  | 3 +--
> >  net/netfilter/nf_tables_api.c    | 3 +--
> >  5 files changed, 5 insertions(+), 10 deletions(-)
> > 
> > diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
> > index fd3f444..7c5e40a 100644
> > --- a/net/netfilter/ipvs/ip_vs_ctl.c
> > +++ b/net/netfilter/ipvs/ip_vs_ctl.c
> > @@ -465,8 +465,7 @@ __ip_vs_bind_svc(struct ip_vs_dest *dest, struct ip_vs_service *svc)
> >  
> >  static void ip_vs_service_free(struct ip_vs_service *svc)
> >  {
> > -	if (svc->stats.cpustats)
> > -		free_percpu(svc->stats.cpustats);
> > +	free_percpu(svc->stats.cpustats);
> >  	kfree(svc);
> >  }
> >  
> > diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c
> > index 1a82b29..0df17ca 100644
> > --- a/net/netfilter/ipvs/ip_vs_pe.c
> > +++ b/net/netfilter/ipvs/ip_vs_pe.c
> > @@ -37,8 +37,7 @@ struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name)
> >  			rcu_read_unlock();
> >  			return pe;
> >  		}
> > -		if (pe->module)
> > -			module_put(pe->module);
> > +		module_put(pe->module);
> >  	}
> >  	rcu_read_unlock();
> >  
> > diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
> > index 4dbcda6..199760c 100644
> > --- a/net/netfilter/ipvs/ip_vs_sched.c
> > +++ b/net/netfilter/ipvs/ip_vs_sched.c
> > @@ -104,8 +104,7 @@ static struct ip_vs_scheduler *ip_vs_sched_getbyname(const char *sched_name)
> >  			mutex_unlock(&ip_vs_sched_mutex);
> >  			return sched;
> >  		}
> > -		if (sched->module)
> > -			module_put(sched->module);
> > +		module_put(sched->module);
> >  	}
> >  
> >  	mutex_unlock(&ip_vs_sched_mutex);
> > diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
> > index eadffb2..cafe28d 100644
> > --- a/net/netfilter/ipvs/ip_vs_sync.c
> > +++ b/net/netfilter/ipvs/ip_vs_sync.c
> > @@ -820,8 +820,7 @@ ip_vs_conn_fill_param_sync(struct net *net, int af, union ip_vs_sync_conn *sc,
> >  
> >  		p->pe_data = kmemdup(pe_data, pe_data_len, GFP_ATOMIC);
> >  		if (!p->pe_data) {
> > -			if (p->pe->module)
> > -				module_put(p->pe->module);
> > +			module_put(p->pe->module);
> >  			return -ENOMEM;
> >  		}
> >  		p->pe_data_len = pe_data_len;
> > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> > index deeb95f..b115f54 100644
> > --- a/net/netfilter/nf_tables_api.c
> > +++ b/net/netfilter/nf_tables_api.c
> > @@ -3472,8 +3472,7 @@ static int nf_tables_abort(struct sk_buff *skb)
> >  			break;
> >  		case NFT_MSG_NEWCHAIN:
> >  			if (nft_trans_chain_update(trans)) {
> > -				if (nft_trans_chain_stats(trans))
> > -					free_percpu(nft_trans_chain_stats(trans));
> > +				free_percpu(nft_trans_chain_stats(trans));
> >  
> >  				nft_trans_destroy(trans);
> >  			} else {
> > -- 
> > 2.1.3
> 
> Regards
> 
> --
> Julian Anastasov <ja@ssi.bg>
> 

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-19 18:49                                       ` SF Markus Elfring
  2014-11-19 19:09                                         ` Daniel Borkmann
@ 2014-11-20  8:47                                         ` Julia Lawall
  2014-11-20  9:22                                           ` Daniel Borkmann
  1 sibling, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-11-20  8:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: John Fastabend, David S. Miller, Jamal Hadi Salim, netdev, LKML,
	kernel-janitors

On Wed, 19 Nov 2014, SF Markus Elfring wrote:

> > Marcus, what tree are you looking at?
>
> I dared to base this update suggestion on the source files
> for Linux 3.17.3. Are newer software developments relevant here?

You should always use linux-next.  You should update it every day.

julia

> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/net/sched/
>
> Regards,
> Markus
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: net: sched: Deletion of an unnecessary check before the function call "kfree"
  2014-11-20  8:47                                         ` Julia Lawall
@ 2014-11-20  9:22                                           ` Daniel Borkmann
  0 siblings, 0 replies; 273+ messages in thread
From: Daniel Borkmann @ 2014-11-20  9:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, John Fastabend, David S. Miller,
	Jamal Hadi Salim, netdev, LKML, kernel-janitors

On 11/20/2014 09:47 AM, Julia Lawall wrote:
> On Wed, 19 Nov 2014, SF Markus Elfring wrote:
>
>>> Marcus, what tree are you looking at?
>>
>> I dared to base this update suggestion on the source files
>> for Linux 3.17.3. Are newer software developments relevant here?
>
> You should always use linux-next.  You should update it every day.

Well, if you send in cleanups to netdev, you should always target
the net-next tree:

   git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git

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

* Re: [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls
  2014-11-20  1:13                                       ` Simon Horman
@ 2014-11-20 12:16                                         ` Pablo Neira Ayuso
  0 siblings, 0 replies; 273+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-20 12:16 UTC (permalink / raw)
  To: Simon Horman
  Cc: Julian Anastasov, SF Markus Elfring, David S. Miller,
	Jozsef Kadlecsik, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Coccinelle

On Thu, Nov 20, 2014 at 10:13:59AM +0900, Simon Horman wrote:
> On Thu, Nov 20, 2014 at 12:26:56AM +0200, Julian Anastasov wrote:
> > 
> > 	Hello,
> > 
> > On Tue, 18 Nov 2014, SF Markus Elfring wrote:
> > 
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Tue, 18 Nov 2014 20:37:05 +0100
> > > 
> > > The functions free_percpu() and module_put() test whether their argument
> > > is NULL and then return immediately. Thus the test around the call is
> > > not needed.
> > > 
> > > This issue was detected by using the Coccinelle software.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > 
> > 	Pablo, the IPVS parts look ok to me,
> > 
> > Acked-by: Julian Anastasov <ja@ssi.bg>
> 
> Acked-by: Simon Horman <horms@verge.net.au>

Applied, thanks.

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

* [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (5 preceding siblings ...)
  2014-11-19 19:55                                   ` [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2014-11-20 13:28                                   ` SF Markus Elfring
  2014-11-21 20:14                                     ` David Miller
  2014-11-20 13:50                                   ` [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                     ` (47 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:28 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:22:47 +0100

The of_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/ibm/emac/core.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 87bd953..3f3fba9 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2323,16 +2323,11 @@ static int emac_check_deps(struct emac_instance *dev,
 
 static void emac_put_deps(struct emac_instance *dev)
 {
-	if (dev->mal_dev)
-		of_dev_put(dev->mal_dev);
-	if (dev->zmii_dev)
-		of_dev_put(dev->zmii_dev);
-	if (dev->rgmii_dev)
-		of_dev_put(dev->rgmii_dev);
-	if (dev->mdio_dev)
-		of_dev_put(dev->mdio_dev);
-	if (dev->tah_dev)
-		of_dev_put(dev->tah_dev);
+	of_dev_put(dev->mal_dev);
+	of_dev_put(dev->zmii_dev);
+	of_dev_put(dev->rgmii_dev);
+	of_dev_put(dev->mdio_dev);
+	of_dev_put(dev->tah_dev);
 }
 
 static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action,
@@ -2371,8 +2366,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 	bus_unregister_notifier(&platform_bus_type, &emac_of_bus_notifier);
 	err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
 	for (i = 0; i < EMAC_DEP_COUNT; i++) {
-		if (deps[i].node)
-			of_node_put(deps[i].node);
+		of_node_put(deps[i].node);
 		if (err && deps[i].ofdev)
 			of_dev_put(deps[i].ofdev);
 	}
@@ -2383,8 +2377,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 		dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev;
 		dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev;
 	}
-	if (deps[EMAC_DEP_PREV_IDX].ofdev)
-		of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
+	of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev);
 	return err;
 }
 
@@ -3113,8 +3106,7 @@ static void __exit emac_exit(void)
 
 	/* Destroy EMAC boot list */
 	for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
-		if (emac_boot_list[i])
-			of_node_put(emac_boot_list[i]);
+		of_node_put(emac_boot_list[i]);
 }
 
 module_init(emac_init);
-- 
2.1.3


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

* [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (6 preceding siblings ...)
  2014-11-20 13:28                                   ` [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put" SF Markus Elfring
@ 2014-11-20 13:50                                   ` SF Markus Elfring
  2014-11-20 17:29                                     ` Sören Brinkmann
  2014-11-21 20:14                                     ` David Miller
  2014-11-20 14:25                                   ` [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
                                                     ` (46 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-20 13:50 UTC (permalink / raw)
  To: Michal Simek, netdev, linux-arm-kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:47:12 +0100

The functions kfree() and of_node_put() test whether their argument is NULL
and then return immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xilinx/ll_temac_main.c   | 3 +--
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index fda5891..af60867 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -224,8 +224,7 @@ static void temac_dma_bd_release(struct net_device *ndev)
 		dma_free_coherent(ndev->dev.parent,
 				sizeof(*lp->tx_bd_v) * TX_BD_NUM,
 				lp->tx_bd_v, lp->tx_bd_p);
-	if (lp->rx_skb)
-		kfree(lp->rx_skb);
+	kfree(lp->rx_skb);
 }
 
 /**
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 28dbbdc..2485879 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1200,8 +1200,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
 
 	unregister_netdev(ndev);
 
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 
 	xemaclite_remove_ndev(ndev);
-- 
2.1.3

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

* [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (7 preceding siblings ...)
  2014-11-20 13:50                                   ` [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-20 14:25                                   ` SF Markus Elfring
  2014-11-20 18:58                                     ` Haiyang Zhang
  2014-11-21 20:15                                     ` David Miller
  2014-11-20 15:16                                   ` [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
                                                     ` (45 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-20 14:25 UTC (permalink / raw)
  To: Haiyang Zhang, K. Y. Srinivasan, devel, netdev
  Cc: Julia Lawall, kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:15:21 +0100

The vfree() function performs also input parameter validation. Thus the test
around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/hyperv/netvsc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index da2d346..ffe7481 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -548,8 +548,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
+	vfree(net_device->sub_cb_buf);
 
 	kfree(net_device);
 	return 0;
-- 
2.1.3

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

* [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (8 preceding siblings ...)
  2014-11-20 14:25                                   ` [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2014-11-20 15:16                                   ` SF Markus Elfring
  2014-11-21 20:16                                     ` David Miller
  2014-11-20 15:50                                   ` [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                     ` (44 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:16 UTC (permalink / raw)
  To: Jan Dumon, linux-usb, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:11:56 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/asix_devices.c | 3 +--
 drivers/net/usb/hso.c          | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index 5d19409..8a7582b 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -499,8 +499,7 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf)
 {
-	if (dev->driver_priv)
-		kfree(dev->driver_priv);
+	kfree(dev->driver_priv);
 }
 
 static const struct ethtool_ops ax88178_ethtool_ops = {
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index babda7d..9c5aa92 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -2746,8 +2746,7 @@ exit:
 		tty_unregister_device(tty_drv, serial->minor);
 		kfree(serial);
 	}
-	if (hso_dev)
-		kfree(hso_dev);
+	kfree(hso_dev);
 	return NULL;
 
 }
-- 
2.1.3

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

* [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (9 preceding siblings ...)
  2014-11-20 15:16                                   ` [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2014-11-20 15:50                                   ` SF Markus Elfring
  2014-11-20 18:04                                     ` Arend van Spriel
  2014-11-29 13:42                                   ` [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
                                                     ` (43 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-20 15:50 UTC (permalink / raw)
  To: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, John W. Linville, linux-wireless,
	brcm80211-dev-list, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:42:51 +0100

The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
their argument is NULL and then return immediately. Thus the test around
the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
 drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
 4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index f55f625..8ff7037 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
 	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
 	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
 	brcmf_sdio_free_glom(bus);
 
 	/* Clear rx control and wake any waiters */
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index 8ea9f28..3a2d014 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
-	if (fwctx->code)
-		release_firmware(fwctx->code);
+	release_firmware(fwctx->code);
 	device_release_driver(fwctx->dev);
 	kfree(fwctx);
 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
index 8f8b937..0cb00dc 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
 		memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ?
 				       len : msgbuf->ioctl_resp_ret_len);
 	}
-	if (skb)
-		brcmu_pkt_buf_free_skb(skb);
+	brcmu_pkt_buf_free_skb(skb);
 
 	return msgbuf->ioctl_resp_status;
 }
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
index 1b47482..ce538a1 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
@@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
 		if (txh)
 			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
 					   sizeof(*txh));
-		if (p)
-			brcmu_pkt_buf_free_skb(p);
+		brcmu_pkt_buf_free_skb(p);
 	}
 
 	if (dma && queue < NFIFO) {
-- 
2.1.3

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

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-11-20 13:50                                   ` [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-20 17:29                                     ` Sören Brinkmann
  2014-11-21 20:14                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: Sören Brinkmann @ 2014-11-20 17:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Michal Simek, netdev, linux-arm-kernel, LKML, kernel-janitors,
	Julia Lawall

On Thu, 2014-11-20 at 02:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Reviewed-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

	Sören

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

* Re: [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls
  2014-11-20 15:50                                   ` [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-20 18:04                                     ` Arend van Spriel
  2015-11-06  7:58                                       ` [PATCH] net: brcm80211: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Arend van Spriel @ 2014-11-20 18:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman,
	John W. Linville, linux-wireless, brcm80211-dev-list, netdev,
	LKML, kernel-janitors, Julia Lawall

On 11/20/14 16:50, SF Markus Elfring wrote:
> From: Markus Elfring<elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:42:51 +0100
>
> The functions brcmu_pkt_buf_free_skb() and release_firmware() test whether
> their argument is NULL and then return immediately. Thus the test around
> the call is not needed.
>
> This issue was detected by using the Coccinelle software.

Goodo for coccinelle and you for running it.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Markus Elfring<elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
>   drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c   | 3 +--
>   drivers/net/wireless/brcm80211/brcmsmac/main.c     | 3 +--
>   4 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index f55f625..8ff7037 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -2539,8 +2539,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
>   	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
>
>   	/* Clear any held glomming stuff */
> -	if (bus->glomd)
> -		brcmu_pkt_buf_free_skb(bus->glomd);
> +	brcmu_pkt_buf_free_skb(bus->glomd);
>   	brcmf_sdio_free_glom(bus);
>
>   	/* Clear rx control and wake any waiters */
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> index 8ea9f28..3a2d014 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> @@ -262,8 +262,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
>
>   fail:
>   	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
> -	if (fwctx->code)
> -		release_firmware(fwctx->code);
> +	release_firmware(fwctx->code);
>   	device_release_driver(fwctx->dev);
>   	kfree(fwctx);
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> index 8f8b937..0cb00dc 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
> @@ -506,8 +506,7 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx,
>   		memcpy(buf, skb->data, (len<  msgbuf->ioctl_resp_ret_len) ?
>   				       len : msgbuf->ioctl_resp_ret_len);
>   	}
> -	if (skb)
> -		brcmu_pkt_buf_free_skb(skb);
> +	brcmu_pkt_buf_free_skb(skb);
>
>   	return msgbuf->ioctl_resp_status;
>   }
> diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> index 1b47482..ce538a1 100644
> --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
> +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
> @@ -1009,8 +1009,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs)
>   		if (txh)
>   			trace_brcms_txdesc(&wlc->hw->d11core->dev, txh,
>   					   sizeof(*txh));
> -		if (p)
> -			brcmu_pkt_buf_free_skb(p);
> +		brcmu_pkt_buf_free_skb(p);
>   	}
>
>   	if (dma&&  queue<  NFIFO) {

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

* RE: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-20 14:25                                   ` [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2014-11-20 18:58                                     ` Haiyang Zhang
  2014-11-21 20:15                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: Haiyang Zhang @ 2014-11-20 18:58 UTC (permalink / raw)
  To: SF Markus Elfring, KY Srinivasan, devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall



> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Thursday, November 20, 2014 9:25 AM
> To: Haiyang Zhang; KY Srinivasan; devel@linuxdriverproject.org;
> netdev@vger.kernel.org
> Cc: LKML; kernel-janitors@vger.kernel.org; Julia Lawall
> Subject: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check
> before the function call "vfree"
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the
> test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Thanks!


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

* Re: [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put"
  2014-11-20 13:28                                   ` [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put" SF Markus Elfring
@ 2014-11-21 20:14                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:28:25 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:22:47 +0100
> 
> The of_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls
  2014-11-20 13:50                                   ` [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls SF Markus Elfring
  2014-11-20 17:29                                     ` Sören Brinkmann
@ 2014-11-21 20:14                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-21 20:14 UTC (permalink / raw)
  To: elfring
  Cc: netdev, kernel-janitors, michal.simek, linux-kernel,
	julia.lawall, linux-arm-kernel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 14:50:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 14:47:12 +0100
> 
> The functions kfree() and of_node_put() test whether their argument is NULL
> and then return immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-20 14:25                                   ` [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
  2014-11-20 18:58                                     ` Haiyang Zhang
@ 2014-11-21 20:15                                     ` David Miller
  2014-11-21 22:15                                       ` SF Markus Elfring
  2014-11-25 21:55                                       ` [PATCH v2] " SF Markus Elfring
  1 sibling, 2 replies; 273+ messages in thread
From: David Miller @ 2014-11-21 20:15 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 15:25:27 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 15:15:21 +0100
> 
> The vfree() function performs also input parameter validation. Thus the test
> around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

This does not apply to the net-next tree, please respin.

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

* Re: [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree"
  2014-11-20 15:16                                   ` [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2014-11-21 20:16                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-21 20:16 UTC (permalink / raw)
  To: elfring
  Cc: j.dumon, linux-usb, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 20 Nov 2014 16:16:16 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 20 Nov 2014 16:11:56 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 20:15                                     ` David Miller
@ 2014-11-21 22:15                                       ` SF Markus Elfring
  2014-11-21 22:27                                         ` David Miller
  2014-11-25 21:55                                       ` [PATCH v2] " SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-21 22:15 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

> This does not apply to the net-next tree, please respin.

Thanks for your reply.

How do you think about to try out the scripts which I published
in March to get more constructive feedback?
Will they run faster for another analysis on current
Linux source files with your test systems (than my computer)?

Regards,
Markus

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 22:15                                       ` SF Markus Elfring
@ 2014-11-21 22:27                                         ` David Miller
  2014-11-23  0:51                                           ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: David Miller @ 2014-11-21 22:27 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 21 Nov 2014 23:15:42 +0100

>> This does not apply to the net-next tree, please respin.
> 
> Thanks for your reply.
> 
> How do you think about to try out the scripts which I published
> in March to get more constructive feedback?

This has nothing to do with me asking you to frame your patches
against the correct tree.

If I had time to investigate automation of changes using such
tools, I would participate in such discussions, but I don't.

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 22:27                                         ` David Miller
@ 2014-11-23  0:51                                           ` SF Markus Elfring
  2014-11-23  1:27                                             ` Eric Dumazet
  2014-11-23  4:36                                             ` David Miller
  0 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-23  0:51 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Haiyang Zhang, kernel-janitors, linux-kernel,
	Julia Lawall, devel

> This has nothing to do with me asking you to frame your patches
> against the correct tree.

I imagine than someone other can also pick up this update suggestion
(a simple change of two lines) quicker before I might try another
software build again from a different commit as a base.

Regards,
Markus

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  0:51                                           ` SF Markus Elfring
@ 2014-11-23  1:27                                             ` Eric Dumazet
  2014-11-23  7:01                                               ` SF Markus Elfring
  2014-11-23  4:36                                             ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: Eric Dumazet @ 2014-11-23  1:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, Haiyang Zhang, kernel-janitors, linux-kernel,
	Julia Lawall, devel, David Miller

On Sun, 2014-11-23 at 01:51 +0100, SF Markus Elfring wrote:
> > This has nothing to do with me asking you to frame your patches
> > against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

I have no idea why someone would do that.

If you don't bother resubmit, nobody will.

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  0:51                                           ` SF Markus Elfring
  2014-11-23  1:27                                             ` Eric Dumazet
@ 2014-11-23  4:36                                             ` David Miller
  2014-11-23  7:18                                               ` SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: David Miller @ 2014-11-23  4:36 UTC (permalink / raw)
  To: elfring
  Cc: haiyangz, kys, devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 01:51:24 +0100

>> This has nothing to do with me asking you to frame your patches
>> against the correct tree.
> 
> I imagine than someone other can also pick up this update suggestion
> (a simple change of two lines) quicker before I might try another
> software build again from a different commit as a base.

Whereas if you learn how to base your changes cleanly on the correct
base now, all of your future submissions will go quickly and smoothly
into my tree.

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  1:27                                             ` Eric Dumazet
@ 2014-11-23  7:01                                               ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:01 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: netdev, Haiyang Zhang, kernel-janitors, linux-kernel,
	Julia Lawall, devel, David Miller

>> I imagine than someone other can also pick up this update suggestion
>> (a simple change of two lines) quicker before I might try another
>> software build again from a different commit as a base.
> 
> I have no idea why someone would do that.

I imagine that other software users (besides me) like developers
and testers might also become curious to try the proposed changes out.

How much will they eventually help to run Linux components a bit faster?


> If you don't bother resubmit, nobody will.

I hope that there are more possibilities for anticipation and acceptance
of source code improvement potentials.
Would you also like to contribute a bit more fine-tuning for the affected
software versions?

Regards,
Markus

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  4:36                                             ` David Miller
@ 2014-11-23  7:18                                               ` SF Markus Elfring
  2014-11-23 18:37                                                 ` David Miller
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-23  7:18 UTC (permalink / raw)
  To: David Miller
  Cc: Haiyang Zhang, K. Y. Srinivasan, devel, netdev, linux-kernel,
	kernel-janitors, Julia Lawall

> Whereas if you learn how to base your changes cleanly on the correct
> base now, all of your future submissions will go quickly and smoothly
> into my tree.

My reluctance to work with more Linux repositories will evolve
over time. The faster affected software versions can be rebuilt
the more it will become interesting to try even more source
code improvements out, won't it?

I find it nice that you could accept update suggestions for
a few other Linux components already.

Regards,
Markus

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

* Re: net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-23  7:18                                               ` SF Markus Elfring
@ 2014-11-23 18:37                                                 ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-23 18:37 UTC (permalink / raw)
  To: elfring
  Cc: netdev, haiyangz, kernel-janitors, linux-kernel, julia.lawall, devel

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 23 Nov 2014 08:18:31 +0100

>> Whereas if you learn how to base your changes cleanly on the correct
>> base now, all of your future submissions will go quickly and smoothly
>> into my tree.
> 
> My reluctance to work with more Linux repositories will evolve
> over time. The faster affected software versions can be rebuilt
> the more it will become interesting to try even more source
> code improvements out, won't it?
> 
> I find it nice that you could accept update suggestions for
> a few other Linux components already.

You are seriously starting to waste our time.

Either resubmit your changes against a clean base, or more on.

Seriously, all I am purely interested in is seeing properly submitted
patches, reviewing them, and then integrating them.  Anything else is
pure noise to me.

Thanks.

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

* [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-21 20:15                                     ` David Miller
  2014-11-21 22:15                                       ` SF Markus Elfring
@ 2014-11-25 21:55                                       ` SF Markus Elfring
  2014-11-25 22:25                                         ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-25 21:55 UTC (permalink / raw)
  To: David Miller, devel, netdev
  Cc: Julia Lawall, Haiyang Zhang, kernel-janitors, linux-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:33:45 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
 drivers/net/hyperv/netvsc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 6b46311..6fc834e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -561,9 +561,7 @@ int netvsc_device_remove(struct hv_device *device)
 	vmbus_close(device->channel);
 
 	/* Release all resources */
-	if (net_device->sub_cb_buf)
-		vfree(net_device->sub_cb_buf);
-
+	vfree(net_device->sub_cb_buf);
 	free_netvsc_device(net_device);
 	return 0;
 }
-- 
2.1.3

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

* Re: [PATCH v2] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree"
  2014-11-25 21:55                                       ` [PATCH v2] " SF Markus Elfring
@ 2014-11-25 22:25                                         ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-11-25 22:25 UTC (permalink / raw)
  To: elfring
  Cc: devel, netdev, haiyangz, kys, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 25 Nov 2014 22:55:34 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 25 Nov 2014 22:33:45 +0100
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>

Applied, thanks.

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

* [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (10 preceding siblings ...)
  2014-11-20 15:50                                   ` [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2014-11-29 13:42                                   ` SF Markus Elfring
  2014-11-29 14:05                                     ` [PATCH 1/1] net: cassini: " SF Markus Elfring
  2014-11-29 15:30                                   ` [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu" SF Markus Elfring
                                                     ` (42 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-29 13:42 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


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

* [PATCH 1/1] net: cassini: Deletion of an unnecessary check before the function call "vfree"
  2014-11-29 13:42                                   ` [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2014-11-29 14:05                                     ` SF Markus Elfring
  2014-12-06  5:14                                       ` David Miller
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:05 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Coccinelle

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 14:34:59 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/sun/cassini.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index 37f87ff..d745808 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -5179,8 +5179,7 @@ static void cas_remove_one(struct pci_dev *pdev)
 	cp = netdev_priv(dev);
 	unregister_netdev(dev);
 
-	if (cp->fw_data)
-		vfree(cp->fw_data);
+	vfree(cp->fw_data);
 
 	mutex_lock(&cp->pm_mutex);
 	cancel_work_sync(&cp->reset_task);
-- 
2.1.3


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

* [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (11 preceding siblings ...)
  2014-11-29 13:42                                   ` [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2014-11-29 15:30                                   ` SF Markus Elfring
  2014-12-02  0:01                                     ` Mahesh Bandewar
  2014-12-06  5:14                                     ` David Miller
  2014-11-29 18:00                                   ` [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
                                                     ` (41 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-29 15:30 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 16:23:20 +0100

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ipvlan/ipvlan_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 96b71b0..feb1853 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -125,8 +125,7 @@ static void ipvlan_uninit(struct net_device *dev)
 	struct ipvl_dev *ipvlan = netdev_priv(dev);
 	struct ipvl_port *port = ipvlan->port;
 
-	if (ipvlan->pcpu_stats)
-		free_percpu(ipvlan->pcpu_stats);
+	free_percpu(ipvlan->pcpu_stats);
 
 	port->count -= 1;
 	if (!port->count)
-- 
2.1.3

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

* [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (12 preceding siblings ...)
  2014-11-29 15:30                                   ` [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu" SF Markus Elfring
@ 2014-11-29 18:00                                   ` SF Markus Elfring
  2014-11-30 17:45                                     ` Lino Sanfilippo
                                                       ` (2 more replies)
  2014-11-30 16:40                                   ` [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
                                                     ` (40 subsequent siblings)
  54 siblings, 3 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-29 18:00 UTC (permalink / raw)
  To: Olof Johansson, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 18:55:40 +0100

The pci_dev_put() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/pasemi/pasemi_mac.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index 30d934d..44e8d7d 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -1837,10 +1837,8 @@ pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	return err;
 
 out:
-	if (mac->iob_pdev)
-		pci_dev_put(mac->iob_pdev);
-	if (mac->dma_pdev)
-		pci_dev_put(mac->dma_pdev);
+	pci_dev_put(mac->iob_pdev);
+	pci_dev_put(mac->dma_pdev);
 
 	free_netdev(dev);
 out_disable_device:
-- 
2.1.3

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

* [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (13 preceding siblings ...)
  2014-11-29 18:00                                   ` [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
@ 2014-11-30 16:40                                   ` SF Markus Elfring
  2014-11-30 16:44                                     ` [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
                                                       ` (2 more replies)
  2015-01-31 16:34                                   ` [PATCH] net: sched: One function call less in em_meta_change() after error detection SF Markus Elfring
                                                     ` (39 subsequent siblings)
  54 siblings, 3 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-30 16:40 UTC (permalink / raw)
  To: Paul Mackerras, linux-ppp, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 17:25:40 +0100

Further update suggestions were taken into account after a patch was applied
from static source code analysis.

Markus Elfring (3):
  Deletion of unnecessary checks before the function call "kfree"
  Less function calls in mppe_alloc() after error detection
  Delete an unnecessary assignment

 drivers/net/ppp/ppp_mppe.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

-- 
2.1.3


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

* [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree"
  2014-11-30 16:40                                   ` [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
@ 2014-11-30 16:44                                     ` SF Markus Elfring
  2014-12-01 12:19                                       ` Sergei Shtylyov
  2014-11-30 16:45                                     ` [PATCH 2/3] net-PPP: Less function calls in mppe_alloc() after error detection SF Markus Elfring
  2014-11-30 16:47                                     ` [PATCH 3/3] net-PPP: Delete an unnecessary assignment SF Markus Elfring
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-30 16:44 UTC (permalink / raw)
  To: Paul Mackerras, linux-ppp, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 17:02:07 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 911b216..7e44212 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -238,8 +238,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 	return (void *)state;
 
 	out_free:
-	    if (state->sha1_digest)
-		kfree(state->sha1_digest);
+	kfree(state->sha1_digest);
 	    if (state->sha1)
 		crypto_free_hash(state->sha1);
 	    if (state->arc4)
@@ -256,13 +255,12 @@ static void mppe_free(void *arg)
 {
 	struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
 	if (state) {
-	    if (state->sha1_digest)
 		kfree(state->sha1_digest);
-	    if (state->sha1)
-		crypto_free_hash(state->sha1);
-	    if (state->arc4)
-		crypto_free_blkcipher(state->arc4);
-	    kfree(state);
+		if (state->sha1)
+			crypto_free_hash(state->sha1);
+		if (state->arc4)
+			crypto_free_blkcipher(state->arc4);
+		kfree(state);
 	}
 }
 
-- 
2.1.3


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

* [PATCH 2/3] net-PPP: Less function calls in mppe_alloc() after error detection
  2014-11-30 16:40                                   ` [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
  2014-11-30 16:44                                     ` [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2014-11-30 16:45                                     ` SF Markus Elfring
  2014-11-30 16:47                                     ` [PATCH 3/3] net-PPP: Delete an unnecessary assignment SF Markus Elfring
  2 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-30 16:45 UTC (permalink / raw)
  To: Paul Mackerras, linux-ppp, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

>From 06c1a0fff81142dfa6d933479e17bb1b45ab9dc7 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 17:07:34 +0100

The functions crypto_free_blkcipher((), crypto_free_hash() and kfree() could be
called in some cases by the mppe_alloc() function during error handling even
if the passed data structure element contained still a null pointer.
This implementation detail could be improved by adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 7e44212..962c1a0 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -197,11 +197,11 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 	if (optlen != CILEN_MPPE + sizeof(state->master_key) ||
 	    options[0] != CI_MPPE || options[1] != CILEN_MPPE)
-		goto out;
+		return NULL;
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
-		goto out;
+		return NULL;
 
 
 	state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
@@ -213,16 +213,16 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 	state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(state->sha1)) {
 		state->sha1 = NULL;
-		goto out_free;
+		goto out_free_blkcipher;
 	}
 
 	digestsize = crypto_hash_digestsize(state->sha1);
 	if (digestsize < MPPE_MAX_KEY_LEN)
-		goto out_free;
+		goto out_free_hash;
 
 	state->sha1_digest = kmalloc(digestsize, GFP_KERNEL);
 	if (!state->sha1_digest)
-		goto out_free;
+		goto out_free_hash;
 
 	/* Save keys. */
 	memcpy(state->master_key, &options[CILEN_MPPE],
@@ -237,14 +237,12 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 	return (void *)state;
 
-	out_free:
-	kfree(state->sha1_digest);
-	    if (state->sha1)
-		crypto_free_hash(state->sha1);
-	    if (state->arc4)
-		crypto_free_blkcipher(state->arc4);
-	    kfree(state);
-	out:
+out_free_hash:
+	crypto_free_hash(state->sha1);
+out_free_blkcipher:
+	crypto_free_blkcipher(state->arc4);
+out_free:
+	kfree(state);
 	return NULL;
 }
 
-- 
2.1.3

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

* [PATCH 3/3] net-PPP: Delete an unnecessary assignment
  2014-11-30 16:40                                   ` [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
  2014-11-30 16:44                                     ` [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
  2014-11-30 16:45                                     ` [PATCH 2/3] net-PPP: Less function calls in mppe_alloc() after error detection SF Markus Elfring
@ 2014-11-30 16:47                                     ` SF Markus Elfring
  2014-11-30 19:59                                       ` Eric Dumazet
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-30 16:47 UTC (permalink / raw)
  To: Paul Mackerras, linux-ppp, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 30 Nov 2014 17:17:36 +0100

The data structure element "arc4" was assigned a null pointer by the
mppe_alloc() function if a previous function call "crypto_alloc_blkcipher"
failed. This assignment became unnecessary with previous source
code adjustments.
Let us delete it from the affected implementation because the element "arc4"
will not be accessible outside the function after the detected
allocation failure.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 962c1a0..d913bc9 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -205,10 +205,8 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 
 	state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
-	if (IS_ERR(state->arc4)) {
-		state->arc4 = NULL;
+	if (IS_ERR(state->arc4))
 		goto out_free;
-	}
 
 	state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(state->sha1)) {
-- 
2.1.3


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

* Re: [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-29 18:00                                   ` [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
@ 2014-11-30 17:45                                     ` Lino Sanfilippo
  2014-11-30 17:47                                       ` Julia Lawall
       [not found]                                       ` <547B579F.10709-Mmb7MZpHnFY@public.gmane.org>
  2014-12-01 20:36                                     ` [PATCH 1/1] " Olof Johansson
  2014-12-06  5:15                                     ` David Miller
  2 siblings, 2 replies; 273+ messages in thread
From: Lino Sanfilippo @ 2014-11-30 17:45 UTC (permalink / raw)
  To: SF Markus Elfring, Olof Johansson, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 29.11.2014 19:00, SF Markus Elfring wrote:

>  out:
> -	if (mac->iob_pdev)
> -		pci_dev_put(mac->iob_pdev);
> -	if (mac->dma_pdev)
> -		pci_dev_put(mac->dma_pdev);
> +	pci_dev_put(mac->iob_pdev);
> +	pci_dev_put(mac->dma_pdev);
>  
>  	free_netdev(dev);
>  out_disable_device:
> 

Hi,

I know there has been some criticism about those kind of "code
improvements" already but i would like to point out just one more thing:

Some of those NULL pointer checks on input parameters may have been
added subsequently to functions. So there may be older kernel versions
out there in which those checks dont exists in some cases. If some of
the now "cleaned up" code is backported to such a kernel chances are
good that those missing checks are overseen. And then neither caller nor
callee is doing the NULL pointer check.

Quite frankly i would vote for the opposite approach: Never rely on the
callee do to checks for NULL and do it always in the caller. An
exception could be for calls on a fast path. But most of those checks
are done on error paths anyway.

Just my 2 cents.

Regards,
Lino

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

* Re: [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-30 17:45                                     ` Lino Sanfilippo
@ 2014-11-30 17:47                                       ` Julia Lawall
  2014-11-30 19:27                                         ` Lino Sanfilippo
       [not found]                                       ` <547B579F.10709-Mmb7MZpHnFY@public.gmane.org>
  1 sibling, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-11-30 17:47 UTC (permalink / raw)
  To: Lino Sanfilippo
  Cc: SF Markus Elfring, Olof Johansson, netdev, LKML, kernel-janitors



On Sun, 30 Nov 2014, Lino Sanfilippo wrote:

> On 29.11.2014 19:00, SF Markus Elfring wrote:
>
> >  out:
> > -	if (mac->iob_pdev)
> > -		pci_dev_put(mac->iob_pdev);
> > -	if (mac->dma_pdev)
> > -		pci_dev_put(mac->dma_pdev);
> > +	pci_dev_put(mac->iob_pdev);
> > +	pci_dev_put(mac->dma_pdev);
> >
> >  	free_netdev(dev);
> >  out_disable_device:
> >
>
> Hi,
>
> I know there has been some criticism about those kind of "code
> improvements" already but i would like to point out just one more thing:
>
> Some of those NULL pointer checks on input parameters may have been
> added subsequently to functions. So there may be older kernel versions
> out there in which those checks dont exists in some cases. If some of
> the now "cleaned up" code is backported to such a kernel chances are
> good that those missing checks are overseen. And then neither caller nor
> callee is doing the NULL pointer check.
>
> Quite frankly i would vote for the opposite approach: Never rely on the
> callee do to checks for NULL and do it always in the caller. An
> exception could be for calls on a fast path. But most of those checks
> are done on error paths anyway.

I have heard of at least one case where the problem you are raising
happened in practice...

julia

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

* Re: [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-30 17:47                                       ` Julia Lawall
@ 2014-11-30 19:27                                         ` Lino Sanfilippo
  2014-11-30 20:40                                           ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Lino Sanfilippo @ 2014-11-30 19:27 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Olof Johansson, netdev, LKML, kernel-janitors

On 30.11.2014 18:47, Julia Lawall wrote:

> 
> I have heard of at least one case where the problem you are raising
> happened in practice...
> 
> julia

If one case is known then there are probably a lot more that have not
been discovered yet.
Maybe this topic should be clarified somewhere (e.g. in "CodingStyle")?
On the other hand i always found it obvious that its the callers
responsibility to only pass sane parameters to the called functions...

Regards,
Lino

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

* Re: [PATCH 3/3] net-PPP: Delete an unnecessary assignment
  2014-11-30 16:47                                     ` [PATCH 3/3] net-PPP: Delete an unnecessary assignment SF Markus Elfring
@ 2014-11-30 19:59                                       ` Eric Dumazet
  2014-11-30 21:16                                         ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Eric Dumazet @ 2014-11-30 19:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Paul Mackerras, linux-ppp, netdev, LKML, kernel-janitors, Julia Lawall

On Sun, 2014-11-30 at 17:47 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 30 Nov 2014 17:17:36 +0100
> 
> The data structure element "arc4" was assigned a null pointer by the
> mppe_alloc() function if a previous function call "crypto_alloc_blkcipher"
> failed. This assignment became unnecessary with previous source
> code adjustments.
> Let us delete it from the affected implementation because the element "arc4"
> will not be accessible outside the function after the detected
> allocation failure.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ppp/ppp_mppe.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> index 962c1a0..d913bc9 100644
> --- a/drivers/net/ppp/ppp_mppe.c
> +++ b/drivers/net/ppp/ppp_mppe.c
> @@ -205,10 +205,8 @@ static void *mppe_alloc(unsigned char *options, int optlen)
>  
> 
>  	state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
> -	if (IS_ERR(state->arc4)) {
> -		state->arc4 = NULL;
> +	if (IS_ERR(state->arc4))
>  		goto out_free;
> -	}
>  
>  	state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
>  	if (IS_ERR(state->sha1)) {

I have no idea why its a patch on its own, and why state->arc4 gets
special treatment while state->sha1 does not.

This definitely belongs to the previous patch, refactoring error
handling in mppe_alloc()

Also, it seems your patches do not fix bugs, so so you need to target
net-next tree, as explained in Documentation/networking/netdev-FAQ.txt

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-30 19:27                                         ` Lino Sanfilippo
@ 2014-11-30 20:40                                           ` SF Markus Elfring
  2014-11-30 21:36                                             ` Lino Sanfilippo
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-30 20:40 UTC (permalink / raw)
  To: Lino Sanfilippo
  Cc: Julia Lawall, Olof Johansson, netdev, LKML, kernel-janitors

> Maybe this topic should be clarified somewhere (e.g. in "CodingStyle")?
> On the other hand i always found it obvious that its the callers
> responsibility to only pass sane parameters to the called functions...

Can you imagine that any more source code places which would benefit from
check adjustments because of defensive programming?

Regards,
Markus

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

* Re: [PATCH 3/3] net-PPP: Delete an unnecessary assignment
  2014-11-30 19:59                                       ` Eric Dumazet
@ 2014-11-30 21:16                                         ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-11-30 21:16 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Paul Mackerras, linux-ppp, netdev, LKML, kernel-janitors, Julia Lawall

> I have no idea why its a patch on its own, and why state->arc4 gets
> special treatment while state->sha1 does not.

I did not fiddle with the data structure element "sha1" because
I assumed that it might be still relevant for the call of a function
like crypto_free_blkcipher().


> This definitely belongs to the previous patch, refactoring error
> handling in mppe_alloc()

I have got different preferences for change distribution over several
patches here.
I find it safer to tackle an assignment clean-up after adjustments
for jump labels.


> Also, it seems your patches do not fix bugs, so so you need to target
> net-next tree, as explained in Documentation/networking/netdev-FAQ.txt

Do you want that I resend my update suggestion?

Regards,
Markus

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-30 20:40                                           ` SF Markus Elfring
@ 2014-11-30 21:36                                             ` Lino Sanfilippo
  0 siblings, 0 replies; 273+ messages in thread
From: Lino Sanfilippo @ 2014-11-30 21:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, Olof Johansson, netdev, LKML, kernel-janitors

On 30.11.2014 21:40, SF Markus Elfring wrote:
>> Maybe this topic should be clarified somewhere (e.g. in "CodingStyle")?
>> On the other hand i always found it obvious that its the callers
>> responsibility to only pass sane parameters to the called functions...
> 
> Can you imagine that any more source code places which would benefit from
> check adjustments because of defensive programming?
> 

I am not sure if i understand your question correctly. But i would not
call sanity checks for function parameters "defensive programming". I
would rather call it not being totally careless. So to me the question
if those checks should be done or not is different from the question
whether there are code parts that would benefit from an adjustment to
defensive programming.

Regards,
Lino

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
       [not found]                                       ` <547B579F.10709-Mmb7MZpHnFY@public.gmane.org>
@ 2014-12-01  1:34                                         ` SF Markus Elfring
  2014-12-01 20:29                                           ` Johannes Berg
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-01  1:34 UTC (permalink / raw)
  To: Lino Sanfilippo, Olof Johansson, netdev-u79uwXL29TY76Z2rM5mHXA,
	backports-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall,
	Luis R. Rodriguez

> I know there has been some criticism about those kind of "code
> improvements" already but i would like to point out just one more thing:
> 
> Some of those NULL pointer checks on input parameters may have been
> added subsequently to functions. So there may be older kernel versions
> out there in which those checks dont exists in some cases. If some of
> the now "cleaned up" code is backported to such a kernel chances are
> good that those missing checks are overseen. And then neither caller nor
> callee is doing the NULL pointer check.

I guess that the Coccinelle software can also help you in this use case.
How do you think about to shield against "unwanted" or unexpected collateral
evolutions with additional inline functions?

I assume that a few backporters can tell you more about their corresponding
software development experiences.
http://www.do-not-panic.com/2014/04/automatic-linux-kernel-backporting-with-coccinelle.html

Regards,
Markus

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

* Re: [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree"
  2014-11-30 16:44                                     ` [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2014-12-01 12:19                                       ` Sergei Shtylyov
  2014-12-01 15:00                                         ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Sergei Shtylyov @ 2014-12-01 12:19 UTC (permalink / raw)
  To: SF Markus Elfring, Paul Mackerras, linux-ppp, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

Hello.

On 11/30/2014 7:44 PM, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 30 Nov 2014 17:02:07 +0100

> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.

> This issue was detected by using the Coccinelle software.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/net/ppp/ppp_mppe.c | 14 ++++++--------
>   1 file changed, 6 insertions(+), 8 deletions(-)

> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> index 911b216..7e44212 100644
> --- a/drivers/net/ppp/ppp_mppe.c
> +++ b/drivers/net/ppp/ppp_mppe.c
> @@ -238,8 +238,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
>   	return (void *)state;
>
>   	out_free:
> -	    if (state->sha1_digest)
> -		kfree(state->sha1_digest);
> +	kfree(state->sha1_digest);

    Please keep this line aligned to the others.

>   	    if (state->sha1)
>   		crypto_free_hash(state->sha1);
>   	    if (state->arc4)

[...]

WBR, Sergei


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

* Re: [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree"
  2014-12-01 12:19                                       ` Sergei Shtylyov
@ 2014-12-01 15:00                                         ` SF Markus Elfring
  2014-12-01 17:11                                           ` Sergei Shtylyov
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-01 15:00 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

>> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
>> index 911b216..7e44212 100644
>> --- a/drivers/net/ppp/ppp_mppe.c
>> +++ b/drivers/net/ppp/ppp_mppe.c
>> @@ -238,8 +238,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
>>       return (void *)state;
>>
>>       out_free:
>> -        if (state->sha1_digest)
>> -        kfree(state->sha1_digest);
>> +    kfree(state->sha1_digest);
> 
>    Please keep this line aligned to the others.

Can it be that the previous source code contained unwanted space
characters at this place?
Do you want indentation fixes as a separate update step?

Regards,
Markus

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

* Re: [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree"
  2014-12-01 15:00                                         ` SF Markus Elfring
@ 2014-12-01 17:11                                           ` Sergei Shtylyov
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Sergei Shtylyov @ 2014-12-01 17:11 UTC (permalink / raw)
  To: SF Markus Elfring, Paul Mackerras, linux-ppp, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 12/01/2014 06:00 PM, SF Markus Elfring wrote:

>>> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
>>> index 911b216..7e44212 100644
>>> --- a/drivers/net/ppp/ppp_mppe.c
>>> +++ b/drivers/net/ppp/ppp_mppe.c
>>> @@ -238,8 +238,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
>>>        return (void *)state;
>>>
>>>        out_free:
>>> -        if (state->sha1_digest)
>>> -        kfree(state->sha1_digest);
>>> +    kfree(state->sha1_digest);

>>     Please keep this line aligned to the others.

> Can it be that the previous source code contained unwanted space
> characters at this place?

    Yes, it seems so.

> Do you want indentation fixes as a separate update step?

    Yes, that would be better to keep it separate.

> Regards,
> Markus

WBR, Sergei

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-12-01  1:34                                         ` SF Markus Elfring
@ 2014-12-01 20:29                                           ` Johannes Berg
  2014-12-01 20:34                                             ` Julia Lawall
  0 siblings, 1 reply; 273+ messages in thread
From: Johannes Berg @ 2014-12-01 20:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Lino Sanfilippo, Olof Johansson, netdev, backports, LKML,
	kernel-janitors, Julia Lawall, Luis R. Rodriguez

On Mon, 2014-12-01 at 02:34 +0100, SF Markus Elfring wrote:

> > Some of those NULL pointer checks on input parameters may have been
> > added subsequently to functions. So there may be older kernel versions
> > out there in which those checks dont exists in some cases. If some of
> > the now "cleaned up" code is backported to such a kernel chances are
> > good that those missing checks are overseen. And then neither caller nor
> > callee is doing the NULL pointer check.

> I assume that a few backporters can tell you more about their corresponding
> software development experiences.
> http://www.do-not-panic.com/2014/04/automatic-linux-kernel-backporting-with-coccinelle.html

In such cases we just provide an appropriate wrapper and replace callers
of the original function by callers of the wrapper, typically with a
#define.

So this kind of evolution is no problem for the (automated) backports
using the backports project - although it can be difficult to detect
such a thing is needed.

johannes

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-12-01 20:29                                           ` Johannes Berg
@ 2014-12-01 20:34                                             ` Julia Lawall
       [not found]                                               ` <alpine.DEB.2.02.1412012134290.2076-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
  0 siblings, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-12-01 20:34 UTC (permalink / raw)
  To: Johannes Berg
  Cc: SF Markus Elfring, Lino Sanfilippo, Olof Johansson, netdev,
	backports, LKML, kernel-janitors, Luis R. Rodriguez



On Mon, 1 Dec 2014, Johannes Berg wrote:

> On Mon, 2014-12-01 at 02:34 +0100, SF Markus Elfring wrote:
> 
> > > Some of those NULL pointer checks on input parameters may have been
> > > added subsequently to functions. So there may be older kernel versions
> > > out there in which those checks dont exists in some cases. If some of
> > > the now "cleaned up" code is backported to such a kernel chances are
> > > good that those missing checks are overseen. And then neither caller nor
> > > callee is doing the NULL pointer check.
> 
> > I assume that a few backporters can tell you more about their corresponding
> > software development experiences.
> > http://www.do-not-panic.com/2014/04/automatic-linux-kernel-backporting-with-coccinelle.html
> 
> In such cases we just provide an appropriate wrapper and replace callers
> of the original function by callers of the wrapper, typically with a
> #define.
> 
> So this kind of evolution is no problem for the (automated) backports
> using the backports project - although it can be difficult to detect
> such a thing is needed.

That is exactly the problem...

julia

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

* Re: [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-29 18:00                                   ` [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
  2014-11-30 17:45                                     ` Lino Sanfilippo
@ 2014-12-01 20:36                                     ` Olof Johansson
  2014-12-06  5:15                                     ` David Miller
  2 siblings, 0 replies; 273+ messages in thread
From: Olof Johansson @ 2014-12-01 20:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Network Development, LKML, kernel-janitors, Julia Lawall

On Sat, Nov 29, 2014 at 10:00 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 18:55:40 +0100
>
> The pci_dev_put() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call
> is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

For this particular case:

Acked-by: Olof Johansson <olof@lixom.net>

Note that the "this might cause problems with backports" case is
mostly academic in the scope of _this particular driver_. It's still a
very valid discussion and issue though.

So I'll be happy to give the ack on this driver, but the larger
problem needs consideration still.


-Olof

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

* Re: [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu"
  2014-11-29 15:30                                   ` [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu" SF Markus Elfring
@ 2014-12-02  0:01                                     ` Mahesh Bandewar
  2014-12-06  5:14                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: Mahesh Bandewar @ 2014-12-02  0:01 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-netdev, LKML, kernel-janitors, Julia Lawall

On Sat, Nov 29, 2014 at 7:30 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 16:23:20 +0100
>
> The free_percpu() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Mahesh Bandewar <maheshb@google.com>
> ---
>  drivers/net/ipvlan/ipvlan_main.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
> index 96b71b0..feb1853 100644
> --- a/drivers/net/ipvlan/ipvlan_main.c
> +++ b/drivers/net/ipvlan/ipvlan_main.c
> @@ -125,8 +125,7 @@ static void ipvlan_uninit(struct net_device *dev)
>         struct ipvl_dev *ipvlan = netdev_priv(dev);
>         struct ipvl_port *port = ipvlan->port;
>
> -       if (ipvlan->pcpu_stats)
> -               free_percpu(ipvlan->pcpu_stats);
> +       free_percpu(ipvlan->pcpu_stats);
>
>         port->count -= 1;
>         if (!port->count)
> --
> 2.1.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
       [not found]                                               ` <alpine.DEB.2.02.1412012134290.2076-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
@ 2014-12-02 16:53                                                 ` Johannes Berg
       [not found]                                                   ` <1417539208.1841.1.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
  2014-12-02 18:45                                                   ` Luis R. Rodriguez
  0 siblings, 2 replies; 273+ messages in thread
From: Johannes Berg @ 2014-12-02 16:53 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Lino Sanfilippo, Olof Johansson,
	netdev-u79uwXL29TY76Z2rM5mHXA, backports-u79uwXL29TY76Z2rM5mHXA,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Luis R. Rodriguez

On Mon, 2014-12-01 at 21:34 +0100, Julia Lawall wrote:

> > So this kind of evolution is no problem for the (automated) backports
> > using the backports project - although it can be difficult to detect
> > such a thing is needed.
> 
> That is exactly the problem...

I'm not convinced though that it should stop such progress in mainline.

johannes

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
       [not found]                                                   ` <1417539208.1841.1.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
@ 2014-12-02 18:35                                                     ` Dan Carpenter
  2014-12-02 20:18                                                       ` Luis R. Rodriguez
  0 siblings, 1 reply; 273+ messages in thread
From: Dan Carpenter @ 2014-12-02 18:35 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Julia Lawall, SF Markus Elfring, Lino Sanfilippo, Olof Johansson,
	netdev-u79uwXL29TY76Z2rM5mHXA, backports-u79uwXL29TY76Z2rM5mHXA,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Luis R. Rodriguez

On Tue, Dec 02, 2014 at 05:53:28PM +0100, Johannes Berg wrote:
> On Mon, 2014-12-01 at 21:34 +0100, Julia Lawall wrote:
> 
> > > So this kind of evolution is no problem for the (automated) backports
> > > using the backports project - although it can be difficult to detect
> > > such a thing is needed.
> > 
> > That is exactly the problem...
> 
> I'm not convinced though that it should stop such progress in mainline.

Is it progress?  These patches match the code look simpler by passing
hiding the NULL check inside a function call.  Calling pci_dev_put(NULL)
doesn't make sense.  Just because a sanity check exists doesn't mean we
should do insane things.

It's easy enough to store which functions have a sanity check in a
database, but to rememember all that as a human being trying to read the
code is impossible.

If we really wanted to make this code cleaner we would introduce more
error labels with better names.

regards,
dan carpenter

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-12-02 16:53                                                 ` Johannes Berg
       [not found]                                                   ` <1417539208.1841.1.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
@ 2014-12-02 18:45                                                   ` Luis R. Rodriguez
  1 sibling, 0 replies; 273+ messages in thread
From: Luis R. Rodriguez @ 2014-12-02 18:45 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Julia Lawall, SF Markus Elfring, Lino Sanfilippo, Olof Johansson,
	netdev, backports, LKML, kernel-janitors

On Tue, Dec 2, 2014 at 11:53 AM, Johannes Berg
<johannes@sipsolutions.net> wrote:
> On Mon, 2014-12-01 at 21:34 +0100, Julia Lawall wrote:
>
>> > So this kind of evolution is no problem for the (automated) backports
>> > using the backports project - although it can be difficult to detect
>> > such a thing is needed.
>>
>> That is exactly the problem...
>
> I'm not convinced though that it should stop such progress in mainline.

I believe this case requires a bit more information explained as to
why it was explained. The "form" of change this patch has is of the
type that can crash systems if the NULL pointer check on the caller
implementation was only added later. We might be able to grammatically
check for this situation in the future if we had a white list / black
list / kernel revision where the NULL check was added but for now we
don't have that and as such care is just required on the developer in
consideration for backports.

It should be up to the maintainer to appreciate the gains of doing
something differently to make it easier for backporting. I obviously
think its a good thing to consider, its extra work though, so only if
the maintainer has some appreciation for backporting would this make
sense.

In this particular case I've reviewed Julia's concern and I've
determined that the patch is safe up to at least v2.6.12-rc2 (which is
where our git history begins on Linus' tree), this is because the
check for NULL has been there since then:

git show 1da177e drivers/pci/pci-driver.c

+void pci_dev_put(struct pci_dev *dev)
+{
+       if (dev)
+               put_device(&dev->dev);
+}

So this type of wide collateral evolution should not cause panics.
Because of this:

Acked-by: Luis R. Rodriguez <mcgrof@suse.com>

But note -- I still think its only good for us to vet these, if we
can't why not? If the maintainer doesn't give a shit that's different,
but if there are folks out there willing to help with vetting then
well, why not :)

PS. Including something like historical vetting as I did above on the
commit log should help folks.

 Luis

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

* Re: net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-12-02 18:35                                                     ` Dan Carpenter
@ 2014-12-02 20:18                                                       ` Luis R. Rodriguez
  0 siblings, 0 replies; 273+ messages in thread
From: Luis R. Rodriguez @ 2014-12-02 20:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Johannes Berg, Julia Lawall, SF Markus Elfring, Lino Sanfilippo,
	Olof Johansson, netdev-u79uwXL29TY76Z2rM5mHXA,
	backports-u79uwXL29TY76Z2rM5mHXA, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, Dec 02, 2014 at 09:35:09PM +0300, Dan Carpenter wrote:
> On Tue, Dec 02, 2014 at 05:53:28PM +0100, Johannes Berg wrote:
> > On Mon, 2014-12-01 at 21:34 +0100, Julia Lawall wrote:
> > 
> > > > So this kind of evolution is no problem for the (automated) backports
> > > > using the backports project - although it can be difficult to detect
> > > > such a thing is needed.
> > > 
> > > That is exactly the problem...
> > 
> > I'm not convinced though that it should stop such progress in mainline.
> 
> Is it progress? 

I like to think of progress as using tools to help fix code where we know
it can be made simpler with a small ammendment: if you can extend the tools
to also vet for safety for backports to avoid crashes even better.

So its a small evolution but we can do better, which is the point you and
Julia are making.

> These patches match the code look simpler by passing
> hiding the NULL check inside a function call.  Calling pci_dev_put(NULL)
> doesn't make sense.  Just because a sanity check exists doesn't mean we
> should do insane things.

It'd crash the system if the function call didn't have the check in place
but having the code in question call pci_dev_put(NULL) is also ludicrious.
Either way in this case I think we shouldn't go beyond analyzing the
function call and if the error check was present before as it is a real
case that has introduced crashes before which Julia wanted to flag.

> It's easy enough to store which functions have a sanity check in a
> database,

This is easy but it adds complexities which I'd prefer to keep on
some other people's workstations. For the developer I think we should
strive to only have: a) git b) Coccinelle c) smatch.

> but to rememember all that as a human being trying to read the
> code is impossible.

Agreed. The problem statement presented by Julia is part of the effort
of addressing the "how do we evolve faster" problem on Linux kernel development,
what you describe adds to the mix of the complexities, and while Oleg does
note that part of this is academic there are those of us who are making things
which are academic immediately practical and a reality for Linux. This is also
how we evolve faster :)

> If we really wanted to make this code cleaner we would introduce more
> error labels with better names.

Can you describe a bit more what you mean here? If we had a label *in code*
on the caller, perhaps a comment, I can see tool-wise how it'd remove the
requirement for a database for immediate analysis for safety here, ie,
we hunt for a label on the code; but other than that its unclear what
you mean here.

If you folks agree with my simplication tool analsysi for safety can
we devise a tag for whitelisting this check for a series of routines?
Where would we put it, in the kernel or a tools package? If in the kernel
we could end up sharing it, so I think that's be better. Perhaps scripts/safety/ ?
Maybe use a header that describes the safety check that is vetted by the rule
present, followed by a list of routines vetted?

Then the Cocci file can preload this and a rule that wants this paranoid check
can include this db file for safety ?

The safety here would require vetting thirough history in git that the routine
has a check in place throughout the routines's history up to a certain point.
I propose we only care up to what kernels are listed on kernel.org as supported.

 Luis

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

* [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-01 17:11                                           ` Sergei Shtylyov
@ 2014-12-04 22:03                                             ` SF Markus Elfring
  2014-12-04 22:10                                               ` [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey() SF Markus Elfring
                                                                 ` (6 more replies)
  0 siblings, 7 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:03 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 22:50:28 +0100

Further update suggestions were taken into account before and after a patch
was applied from static source code analysis.

Markus Elfring (6):
  Replacement of a printk() call by pr_warn() in mppe_rekey()
  Fix indentation
  Deletion of unnecessary checks before the function call "kfree"
  Less function calls in mppe_alloc() after error detection
  Delete an unnecessary assignment in mppe_alloc()
  Delete another unnecessary assignment in mppe_alloc()

 drivers/net/ppp/ppp_mppe.c | 49 +++++++++++++++++++---------------------------
 1 file changed, 20 insertions(+), 29 deletions(-)

-- 
2.1.3


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

* [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
@ 2014-12-04 22:10                                               ` SF Markus Elfring
  2014-12-04 22:23                                                 ` Joe Perches
  2014-12-04 22:13                                               ` [PATCH v2 2/6] net-PPP: Fix indentation SF Markus Elfring
                                                                 ` (5 subsequent siblings)
  6 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:10 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 18:28:52 +0100

The mppe_rekey() function contained a few update candidates.
* Curly brackets were still used around a single function call "printk".
* Unwanted space characters

Let us improve these implementation details according to the current Linux
coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 911b216..84b7bce 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
 		setup_sg(sg_in, state->sha1_digest, state->keylen);
 		setup_sg(sg_out, state->session_key, state->keylen);
 		if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
-					     state->keylen) != 0) {
-    		    printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
-		}
+					     state->keylen) != 0)
+			pr_warn("mppe_rekey: cipher_encrypt failed\n");
 	} else {
 		memcpy(state->session_key, state->sha1_digest, state->keylen);
 	}
-- 
2.1.3


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

* [PATCH v2 2/6] net-PPP: Fix indentation
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
  2014-12-04 22:10                                               ` [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey() SF Markus Elfring
@ 2014-12-04 22:13                                               ` SF Markus Elfring
  2014-12-04 22:15                                               ` [PATCH v2 3/6] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
                                                                 ` (4 subsequent siblings)
  6 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:13 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 22:15:20 +0100

The implementations of the functions "mppe_alloc" and "mppe_free" contained
unwanted space characters.

Let us improve the indentation according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 84b7bce..b80af29 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -236,15 +236,15 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 	return (void *)state;
 
-	out_free:
-	    if (state->sha1_digest)
+out_free:
+	if (state->sha1_digest)
 		kfree(state->sha1_digest);
-	    if (state->sha1)
+	if (state->sha1)
 		crypto_free_hash(state->sha1);
-	    if (state->arc4)
+	if (state->arc4)
 		crypto_free_blkcipher(state->arc4);
-	    kfree(state);
-	out:
+	kfree(state);
+out:
 	return NULL;
 }
 
@@ -255,13 +255,13 @@ static void mppe_free(void *arg)
 {
 	struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
 	if (state) {
-	    if (state->sha1_digest)
-		kfree(state->sha1_digest);
-	    if (state->sha1)
-		crypto_free_hash(state->sha1);
-	    if (state->arc4)
-		crypto_free_blkcipher(state->arc4);
-	    kfree(state);
+		if (state->sha1_digest)
+			kfree(state->sha1_digest);
+		if (state->sha1)
+			crypto_free_hash(state->sha1);
+		if (state->arc4)
+			crypto_free_blkcipher(state->arc4);
+		kfree(state);
 	}
 }
 
-- 
2.1.3

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

* [PATCH v2 3/6] net-PPP: Deletion of unnecessary checks before the function call "kfree"
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
  2014-12-04 22:10                                               ` [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey() SF Markus Elfring
  2014-12-04 22:13                                               ` [PATCH v2 2/6] net-PPP: Fix indentation SF Markus Elfring
@ 2014-12-04 22:15                                               ` SF Markus Elfring
  2014-12-04 22:16                                               ` [PATCH v2 4/6] net-PPP: Less function calls in mppe_alloc() after error detection SF Markus Elfring
                                                                 ` (3 subsequent siblings)
  6 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:15 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 22:22:23 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index b80af29..94ff216 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -237,8 +237,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 	return (void *)state;
 
 out_free:
-	if (state->sha1_digest)
-		kfree(state->sha1_digest);
+	kfree(state->sha1_digest);
 	if (state->sha1)
 		crypto_free_hash(state->sha1);
 	if (state->arc4)
@@ -255,8 +254,7 @@ static void mppe_free(void *arg)
 {
 	struct ppp_mppe_state *state = (struct ppp_mppe_state *) arg;
 	if (state) {
-		if (state->sha1_digest)
-			kfree(state->sha1_digest);
+		kfree(state->sha1_digest);
 		if (state->sha1)
 			crypto_free_hash(state->sha1);
 		if (state->arc4)
-- 
2.1.3

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

* [PATCH v2 4/6] net-PPP: Less function calls in mppe_alloc() after error detection
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
                                                                 ` (2 preceding siblings ...)
  2014-12-04 22:15                                               ` [PATCH v2 3/6] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2014-12-04 22:16                                               ` SF Markus Elfring
  2014-12-04 22:18                                               ` [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc() SF Markus Elfring
                                                                 ` (2 subsequent siblings)
  6 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:16 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 22:30:20 +0100

The functions crypto_free_blkcipher((), crypto_free_hash() and kfree() could be
called in some cases by the mppe_alloc() function during error handling even
if the passed data structure element contained still a null pointer.

This implementation detail could be improved by adjustments for jump labels.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 94ff216..c82198f 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -196,11 +196,11 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 	if (optlen != CILEN_MPPE + sizeof(state->master_key) ||
 	    options[0] != CI_MPPE || options[1] != CILEN_MPPE)
-		goto out;
+		return NULL;
 
 	state = kzalloc(sizeof(*state), GFP_KERNEL);
 	if (state == NULL)
-		goto out;
+		return NULL;
 
 
 	state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
@@ -212,16 +212,16 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 	state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(state->sha1)) {
 		state->sha1 = NULL;
-		goto out_free;
+		goto out_free_blkcipher;
 	}
 
 	digestsize = crypto_hash_digestsize(state->sha1);
 	if (digestsize < MPPE_MAX_KEY_LEN)
-		goto out_free;
+		goto out_free_hash;
 
 	state->sha1_digest = kmalloc(digestsize, GFP_KERNEL);
 	if (!state->sha1_digest)
-		goto out_free;
+		goto out_free_hash;
 
 	/* Save keys. */
 	memcpy(state->master_key, &options[CILEN_MPPE],
@@ -236,14 +236,12 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 	return (void *)state;
 
+out_free_hash:
+	crypto_free_hash(state->sha1);
+out_free_blkcipher:
+	crypto_free_blkcipher(state->arc4);
 out_free:
-	kfree(state->sha1_digest);
-	if (state->sha1)
-		crypto_free_hash(state->sha1);
-	if (state->arc4)
-		crypto_free_blkcipher(state->arc4);
 	kfree(state);
-out:
 	return NULL;
 }
 
-- 
2.1.3

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

* [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc()
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
                                                                 ` (3 preceding siblings ...)
  2014-12-04 22:16                                               ` [PATCH v2 4/6] net-PPP: Less function calls in mppe_alloc() after error detection SF Markus Elfring
@ 2014-12-04 22:18                                               ` SF Markus Elfring
  2014-12-05 12:22                                                 ` Dan Carpenter
  2014-12-04 22:20                                               ` [PATCH v2 6/6] net-PPP: Delete another " SF Markus Elfring
  2014-12-09 19:54                                               ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks David Miller
  6 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:18 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 22:33:34 +0100

The data structure element "arc4" was assigned a null pointer by the
mppe_alloc() function if a previous function call "crypto_alloc_blkcipher"
failed. This assignment became unnecessary with previous source
code adjustments.

Let us delete it from the affected implementation because the element "arc4"
will not be accessible outside the function after the detected
allocation failure.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index c82198f..b7db4b1 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -204,10 +204,8 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 
 
 	state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
-	if (IS_ERR(state->arc4)) {
-		state->arc4 = NULL;
+	if (IS_ERR(state->arc4))
 		goto out_free;
-	}
 
 	state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(state->sha1)) {
-- 
2.1.3


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

* [PATCH v2 6/6] net-PPP: Delete another unnecessary assignment in mppe_alloc()
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
                                                                 ` (4 preceding siblings ...)
  2014-12-04 22:18                                               ` [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc() SF Markus Elfring
@ 2014-12-04 22:20                                               ` SF Markus Elfring
  2014-12-05 12:23                                                 ` Dan Carpenter
  2014-12-09 19:54                                               ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks David Miller
  6 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:20 UTC (permalink / raw)
  To: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 4 Dec 2014 22:42:30 +0100

The data structure element "sha1" was assigned a null pointer by the
mppe_alloc() after a function call "crypto_alloc_hash" failed.
It was determined that this element was not accessed by the implementation
of the crypto_free_blkcipher() function.

Let us delete it from the affected implementation because the element "sha1"
will not be accessible outside the function after the detected
allocation failure.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ppp/ppp_mppe.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index b7db4b1..32cb054 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -208,10 +208,8 @@ static void *mppe_alloc(unsigned char *options, int optlen)
 		goto out_free;
 
 	state->sha1 = crypto_alloc_hash("sha1", 0, CRYPTO_ALG_ASYNC);
-	if (IS_ERR(state->sha1)) {
-		state->sha1 = NULL;
+	if (IS_ERR(state->sha1))
 		goto out_free_blkcipher;
-	}
 
 	digestsize = crypto_hash_digestsize(state->sha1);
 	if (digestsize < MPPE_MAX_KEY_LEN)
-- 
2.1.3


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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:10                                               ` [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey() SF Markus Elfring
@ 2014-12-04 22:23                                                 ` Joe Perches
  2014-12-04 22:27                                                   ` SF Markus Elfring
  2014-12-05  7:21                                                   ` Julia Lawall
  0 siblings, 2 replies; 273+ messages in thread
From: Joe Perches @ 2014-12-04 22:23 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Thu, 2014-12-04 at 23:10 +0100, SF Markus Elfring wrote:
> The mppe_rekey() function contained a few update candidates.
> * Curly brackets were still used around a single function call "printk".
> * Unwanted space characters
> 
> Let us improve these implementation details according to the current Linux
> coding style convention.

trivia:

> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
[]
> @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
>  		setup_sg(sg_in, state->sha1_digest, state->keylen);
>  		setup_sg(sg_out, state->session_key, state->keylen);
>  		if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
> -					     state->keylen) != 0) {
> -    		    printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
> -		}
> +					     state->keylen) != 0)
> +			pr_warn("mppe_rekey: cipher_encrypt failed\n");

It's generally nicer to replace embedded function names
with "%s: ", __func__

			pr_warn("%s: cipher_encrypt failed\n", __func__);

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:23                                                 ` Joe Perches
@ 2014-12-04 22:27                                                   ` SF Markus Elfring
  2014-12-04 22:45                                                     ` Joe Perches
  2014-12-05  7:21                                                   ` Julia Lawall
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-04 22:27 UTC (permalink / raw)
  To: Joe Perches
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

>> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> []
>> @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
>>  		setup_sg(sg_in, state->sha1_digest, state->keylen);
>>  		setup_sg(sg_out, state->session_key, state->keylen);
>>  		if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
>> -					     state->keylen) != 0) {
>> -    		    printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
>> -		}
>> +					     state->keylen) != 0)
>> +			pr_warn("mppe_rekey: cipher_encrypt failed\n");
> 
> It's generally nicer to replace embedded function names
> with "%s: ", __func__
> 
> 			pr_warn("%s: cipher_encrypt failed\n", __func__);

Do you want that I send a third patch series for the fine-tuning of these parameters?

Regards,
Martkus


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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:27                                                   ` SF Markus Elfring
@ 2014-12-04 22:45                                                     ` Joe Perches
  2014-12-05  6:26                                                       ` Julia Lawall
  2014-12-05  7:18                                                       ` SF Markus Elfring
  0 siblings, 2 replies; 273+ messages in thread
From: Joe Perches @ 2014-12-04 22:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Thu, 2014-12-04 at 23:27 +0100, SF Markus Elfring wrote:
> >> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> > []
> >> @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
> >>  		setup_sg(sg_in, state->sha1_digest, state->keylen);
> >>  		setup_sg(sg_out, state->session_key, state->keylen);
> >>  		if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
> >> -					     state->keylen) != 0) {
> >> -    		    printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
> >> -		}
> >> +					     state->keylen) != 0)
> >> +			pr_warn("mppe_rekey: cipher_encrypt failed\n");
> > 
> > It's generally nicer to replace embedded function names
> > with "%s: ", __func__
> > 
> > 			pr_warn("%s: cipher_encrypt failed\n", __func__);
> 
> Do you want that I send a third patch series for the fine-tuning of these parameters?

If you want.

I just wanted you to be aware of it for future patches.

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:45                                                     ` Joe Perches
@ 2014-12-05  6:26                                                       ` Julia Lawall
  2014-12-05  8:04                                                         ` SF Markus Elfring
  2014-12-05  7:18                                                       ` SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-12-05  6:26 UTC (permalink / raw)
  To: Joe Perches
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors, Julia Lawall

On Thu, 4 Dec 2014, Joe Perches wrote:

> On Thu, 2014-12-04 at 23:27 +0100, SF Markus Elfring wrote:
> > >> diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> > > []
> > >> @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
> > >>  		setup_sg(sg_in, state->sha1_digest, state->keylen);
> > >>  		setup_sg(sg_out, state->session_key, state->keylen);
> > >>  		if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
> > >> -					     state->keylen) != 0) {
> > >> -    		    printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
> > >> -		}
> > >> +					     state->keylen) != 0)
> > >> +			pr_warn("mppe_rekey: cipher_encrypt failed\n");
> > > 
> > > It's generally nicer to replace embedded function names
> > > with "%s: ", __func__
> > > 
> > > 			pr_warn("%s: cipher_encrypt failed\n", __func__);
> > 
> > Do you want that I send a third patch series for the fine-tuning of these parameters?
> 
> If you want.
> 
> I just wanted you to be aware of it for future patches.

Markus, are you sure that you cannot use netdev_warn in this case?

julia

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:45                                                     ` Joe Perches
  2014-12-05  6:26                                                       ` Julia Lawall
@ 2014-12-05  7:18                                                       ` SF Markus Elfring
  2014-12-05  7:57                                                         ` Joe Perches
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-05  7:18 UTC (permalink / raw)
  To: Joe Perches
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

>>> It's generally nicer to replace embedded function names
>>> with "%s: ", __func__
>>>
>>> 			pr_warn("%s: cipher_encrypt failed\n", __func__);
>>
>> Do you want that I send a third patch series for the fine-tuning of these parameters?
> 
> If you want.

Would "a committer" fix such a small source code adjustment also without a resend of
a patch series?


> I just wanted you to be aware of it for future patches.

Thanks for your tip.

Does it make sense to express such implementation details in the Linux coding
style documentation more explicitly (besides the fact that this update suggestion
was also triggered by a warning from the script "checkpatch.pl").

Regards,
Markus

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-04 22:23                                                 ` Joe Perches
  2014-12-04 22:27                                                   ` SF Markus Elfring
@ 2014-12-05  7:21                                                   ` Julia Lawall
  2014-12-05  7:41                                                     ` Joe Perches
  1 sibling, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-12-05  7:21 UTC (permalink / raw)
  To: Joe Perches
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors



On Thu, 4 Dec 2014, Joe Perches wrote:

> On Thu, 2014-12-04 at 23:10 +0100, SF Markus Elfring wrote:
> > The mppe_rekey() function contained a few update candidates.
> > * Curly brackets were still used around a single function call "printk".
> > * Unwanted space characters
> > 
> > Let us improve these implementation details according to the current Linux
> > coding style convention.
> 
> trivia:
> 
> > diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
> []
> > @@ -172,9 +172,8 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
> >  		setup_sg(sg_in, state->sha1_digest, state->keylen);
> >  		setup_sg(sg_out, state->session_key, state->keylen);
> >  		if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
> > -					     state->keylen) != 0) {
> > -    		    printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
> > -		}
> > +					     state->keylen) != 0)
> > +			pr_warn("mppe_rekey: cipher_encrypt failed\n");
> 
> It's generally nicer to replace embedded function names
> with "%s: ", __func__
> 
> 			pr_warn("%s: cipher_encrypt failed\n", __func__);

Doing so may potentially allow some strings to be shared, thus saving a 
little space.  Perhaps not in this case, though.

julia

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  7:21                                                   ` Julia Lawall
@ 2014-12-05  7:41                                                     ` Joe Perches
  2014-12-07 10:44                                                       ` Julia Lawall
  0 siblings, 1 reply; 273+ messages in thread
From: Joe Perches @ 2014-12-05  7:41 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors

On Fri, 2014-12-05 at 08:21 +0100, Julia Lawall wrote:
> On Thu, 4 Dec 2014, Joe Perches wrote:
> > It's generally nicer to replace embedded function names
> > with "%s: ", __func__
> > 
> > 			pr_warn("%s: cipher_encrypt failed\n", __func__);
> 
> Doing so may potentially allow some strings to be shared, thus saving a 
> little space.  Perhaps not in this case, though.

It's not necessarily a code size savings in any case.

It can be, but the real benefits are stylistic
consistency and lack of mismatch between function
name and message.

If the code is refactored or copy/pasted into another
function, a moderately common defect is not modifying
the embedded function name in the message.

There may be some smallish savings if ever these
__func__ uses were converted to use %pf via some
internal standardized mechanism.

A negative to that approach is inlined functions would
take the function name of the parent not keep the
inlined function name.



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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  7:18                                                       ` SF Markus Elfring
@ 2014-12-05  7:57                                                         ` Joe Perches
  2014-12-05  8:49                                                           ` SF Markus Elfring
  2014-12-05 22:35                                                           ` terry white
  0 siblings, 2 replies; 273+ messages in thread
From: Joe Perches @ 2014-12-05  7:57 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Fri, 2014-12-05 at 08:18 +0100, SF Markus Elfring wrote:
> >>> It's generally nicer to replace embedded function names
> >>> with "%s: ", __func__
> >>>
> >>> 			pr_warn("%s: cipher_encrypt failed\n", __func__);
> >>
> >> Do you want that I send a third patch series for the fine-tuning of these parameters?
> > 
> > If you want.
> 
> Would "a committer" fix such a small source code adjustment also without a resend of
> a patch series?

Depends on the committer.  Some might, most wouldn't.

drivers/net/ppp doesn't have a specific maintainer.

The networking maintainer generally asks for resends
of patches that don't suit his taste, but lots of
non-perfect patches still get applied there.

It's a process, and it's not immediate.  Wait to see
if these get applied as-is.  If the embedded function
name use, which is trivial, bothers you, send another
patch later on that changes it.

> Does it make sense to express such implementation details in the Linux coding
> style documentation more explicitly (besides the fact that this update suggestion
> was also triggered by a warning from the script "checkpatch.pl").

Probably not.

Overly formalized coding style rules are perhaps
more of a barrier to entry than most want.



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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  6:26                                                       ` Julia Lawall
@ 2014-12-05  8:04                                                         ` SF Markus Elfring
  2014-12-05  8:40                                                           ` Julia Lawall
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-05  8:04 UTC (permalink / raw)
  To: Julia Lawall, Joe Perches
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors

> Markus, are you sure that you cannot use netdev_warn in this case?

No. - I did not become familiar enough with the software infrastructure around
the mppe_rekey() function.

I do not see so far how I could determine a pointer for the first parameter there.
The data structure "ppp_mppe_state" (which is referenced by the input variable
"state") does not contain corresponding context information, does it?

Regards,
Markus

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  8:04                                                         ` SF Markus Elfring
@ 2014-12-05  8:40                                                           ` Julia Lawall
  0 siblings, 0 replies; 273+ messages in thread
From: Julia Lawall @ 2014-12-05  8:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, Joe Perches, Sergei Shtylyov, Paul Mackerras,
	linux-ppp, netdev, Eric Dumazet, LKML, kernel-janitors



On Fri, 5 Dec 2014, SF Markus Elfring wrote:

> > Markus, are you sure that you cannot use netdev_warn in this case?
>
> No. - I did not become familiar enough with the software infrastructure around
> the mppe_rekey() function.
>
> I do not see so far how I could determine a pointer for the first parameter there.
> The data structure "ppp_mppe_state" (which is referenced by the input variable
> "state") does not contain corresponding context information, does it?

Indeed, I also don't see anything promising.

julia

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  7:57                                                         ` Joe Perches
@ 2014-12-05  8:49                                                           ` SF Markus Elfring
  2014-12-05 22:35                                                           ` terry white
  1 sibling, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-05  8:49 UTC (permalink / raw)
  To: Joe Perches
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

> It's a process, and it's not immediate.  Wait to see
> if these get applied as-is.

Thanks for your constructive feedback.


> If the embedded function name use, which is trivial, bothers you,
> send another patch later on that changes it.

Not really at the moment ...

I guess that I would prefer a general development of another semantic
patch approach according to your request with the topic "Finding embedded
function names?" a moment ago.
https://systeme.lip6.fr/pipermail/cocci/2014-December/001517.html
http://article.gmane.org/gmane.comp.version-control.coccinelle/4399

Regards,
Markus

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

* Re: [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc()
  2014-12-04 22:18                                               ` [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc() SF Markus Elfring
@ 2014-12-05 12:22                                                 ` Dan Carpenter
  2014-12-05 12:44                                                   ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Dan Carpenter @ 2014-12-05 12:22 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Thu, Dec 04, 2014 at 11:18:41PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 4 Dec 2014 22:33:34 +0100
> 
> The data structure element "arc4" was assigned a null pointer by the
> mppe_alloc() function if a previous function call "crypto_alloc_blkcipher"
> failed.

No.  crypto_alloc_blkcipher() returns error pointers and not NULL.

This patch creates a bug.

regards,
dan carpenter

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

* Re: [PATCH v2 6/6] net-PPP: Delete another unnecessary assignment in mppe_alloc()
  2014-12-04 22:20                                               ` [PATCH v2 6/6] net-PPP: Delete another " SF Markus Elfring
@ 2014-12-05 12:23                                                 ` Dan Carpenter
  2014-12-05 12:50                                                   ` SF Markus Elfring
  2014-12-05 13:58                                                   ` Dan Carpenter
  0 siblings, 2 replies; 273+ messages in thread
From: Dan Carpenter @ 2014-12-05 12:23 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Thu, Dec 04, 2014 at 11:20:21PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 4 Dec 2014 22:42:30 +0100
> 
> The data structure element "sha1" was assigned a null pointer by the
> mppe_alloc() after a function call "crypto_alloc_hash" failed.

This patch is also buggy.

regards,
dan carpenter

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

* Re: [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc()
  2014-12-05 12:22                                                 ` Dan Carpenter
@ 2014-12-05 12:44                                                   ` SF Markus Elfring
  2014-12-05 13:57                                                     ` Dan Carpenter
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-05 12:44 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

>> The data structure element "arc4" was assigned a null pointer by the
>> mppe_alloc() function if a previous function call "crypto_alloc_blkcipher"
>> failed.
> 
> crypto_alloc_blkcipher() returns error pointers and not NULL.

That is true.


> This patch creates a bug.

Please explain: How?

Did you notice that the data structure element "arc4" was reset
to a null pointer if a failure was detected for the function
call "crypto_alloc_blkcipher"?

Do you find this specific assignment still necessary for exception
handling in the implementation of mppe_alloc() function?

Regards,
Markus

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

* Re: [PATCH v2 6/6] net-PPP: Delete another unnecessary assignment in mppe_alloc()
  2014-12-05 12:23                                                 ` Dan Carpenter
@ 2014-12-05 12:50                                                   ` SF Markus Elfring
  2014-12-05 13:58                                                   ` Dan Carpenter
  1 sibling, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-05 12:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

>> The data structure element "sha1" was assigned a null pointer by the
>> mppe_alloc() after a function call "crypto_alloc_hash" failed.
> 
> This patch is also buggy.

Do you really want to keep a variable reset after a detected failure?

Regards,
Markus

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

* Re: [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc()
  2014-12-05 12:44                                                   ` SF Markus Elfring
@ 2014-12-05 13:57                                                     ` Dan Carpenter
  2014-12-05 21:00                                                       ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Dan Carpenter @ 2014-12-05 13:57 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Fri, Dec 05, 2014 at 01:44:30PM +0100, SF Markus Elfring wrote:
> >> The data structure element "arc4" was assigned a null pointer by the
> >> mppe_alloc() function if a previous function call "crypto_alloc_blkcipher"
> >> failed.
> > 
> > crypto_alloc_blkcipher() returns error pointers and not NULL.
> 
> That is true.
> 

Oh.  In that case, I misunderstood what you wrote.  Looking at it now,
this patch is actually ok.

regards,
dan carpenter


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

* Re: [PATCH v2 6/6] net-PPP: Delete another unnecessary assignment in mppe_alloc()
  2014-12-05 12:23                                                 ` Dan Carpenter
  2014-12-05 12:50                                                   ` SF Markus Elfring
@ 2014-12-05 13:58                                                   ` Dan Carpenter
  1 sibling, 0 replies; 273+ messages in thread
From: Dan Carpenter @ 2014-12-05 13:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

On Fri, Dec 05, 2014 at 03:23:15PM +0300, Dan Carpenter wrote:
> On Thu, Dec 04, 2014 at 11:20:21PM +0100, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Thu, 4 Dec 2014 22:42:30 +0100
> > 
> > The data structure element "sha1" was assigned a null pointer by the
> > mppe_alloc() after a function call "crypto_alloc_hash" failed.
> 
> This patch is also buggy.

Actually it's ok.  I was just confused by the changelog.

Sorry about that, Markus.

regards,
dan carpenter

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

* Re: [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc()
  2014-12-05 13:57                                                     ` Dan Carpenter
@ 2014-12-05 21:00                                                       ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-05 21:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	LKML, kernel-janitors, Julia Lawall

>> That is true.
> 
> In that case, I misunderstood what you wrote.

I find it a bit interesting how this misunderstanding could happen here somehow.


> Looking at it now, this patch is actually ok.

Does that mean that you would like to add any tag like "Acked-by" or "Reviewed-by"
to any of the proposed six update steps?

Regards,
Markus

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  7:57                                                         ` Joe Perches
  2014-12-05  8:49                                                           ` SF Markus Elfring
@ 2014-12-05 22:35                                                           ` terry white
  1 sibling, 0 replies; 273+ messages in thread
From: terry white @ 2014-12-05 22:35 UTC (permalink / raw)
  To: joe; +Cc: linux-ppp, netdev, linux-kernel, kernel-janitors

... ciao:

: on "12-4-2014" "Joe Perches" writ:
: > Does it make sense to express such implementation details in the Linux 
: > coding style documentation more explicitly (besides the fact that this 
: > update suggestion was also triggered by a warning from the script 
: > "checkpatch.pl".
: 
: Probably not.
: 
: Overly formalized coding style rules are perhaps
: more of a barrier to entry than most want.
 
   funny you should mention that.  as nothing more than a casual observer, 
i'm noticing a "TIRED" sensation reading this thread.  i have "0" 
confidence a "SERIOUS" participant's enthusiasm would remain untested.
 
   however, the "checkpatch.pl" warning suggests an assumed 'custom'. i 
can't tell if this a 'serious' issue, or "pickin' fly shit out of pepper".
 
   but from my reading of it, the "CODE" , and the "logic" driving it, is 
not the problem.

    season's best ...

-- 
... it's not what you see ,
    but in stead , notice ...

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

* Re: [PATCH 1/1] net: cassini: Deletion of an unnecessary check before the function call "vfree"
  2014-11-29 14:05                                     ` [PATCH 1/1] net: cassini: " SF Markus Elfring
@ 2014-12-06  5:14                                       ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-12-06  5:14 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, cocci

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 15:05:33 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 14:34:59 +0100
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu"
  2014-11-29 15:30                                   ` [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu" SF Markus Elfring
  2014-12-02  0:01                                     ` Mahesh Bandewar
@ 2014-12-06  5:14                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2014-12-06  5:14 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 16:30:27 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 16:23:20 +0100
> 
> The free_percpu() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put"
  2014-11-29 18:00                                   ` [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
  2014-11-30 17:45                                     ` Lino Sanfilippo
  2014-12-01 20:36                                     ` [PATCH 1/1] " Olof Johansson
@ 2014-12-06  5:15                                     ` David Miller
  2 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2014-12-06  5:15 UTC (permalink / raw)
  To: elfring; +Cc: olof, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 19:00:17 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 29 Nov 2014 18:55:40 +0100
> 
> The pci_dev_put() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-05  7:41                                                     ` Joe Perches
@ 2014-12-07 10:44                                                       ` Julia Lawall
  2014-12-07 12:30                                                         ` Joe Perches
  0 siblings, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-12-07 10:44 UTC (permalink / raw)
  To: Joe Perches
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors

> A negative to that approach is inlined functions would
> take the function name of the parent not keep the
> inlined function name.

I tried the following:

#include <stdio.h>

inline int foo() {
  printf("%s %x\n",__func__,0x12345);
}

int main () {
  foo();
}

The assembly code generated for main is:

0000000000400470 <main>:
  400470:       b9 45 23 01 00          mov    $0x12345,%ecx
  400475:       ba 4b 06 40 00          mov    $0x40064b,%edx
  40047a:       be 44 06 40 00          mov    $0x400644,%esi
  40047f:       bf 01 00 00 00          mov    $0x1,%edi
  400484:       31 c0                   xor    %eax,%eax
  400486:       e9 d5 ff ff ff          jmpq   400460 <__printf_chk@plt>

That is, the call to foo seems tom be inlined.

But the output is:

foo 12345

So it seems that __func__ is determined before inlining.

julia

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-07 10:44                                                       ` Julia Lawall
@ 2014-12-07 12:30                                                         ` Joe Perches
  2014-12-07 12:36                                                           ` Julia Lawall
  0 siblings, 1 reply; 273+ messages in thread
From: Joe Perches @ 2014-12-07 12:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors

On Sun, 2014-12-07 at 11:44 +0100, Julia Lawall wrote:
> > A negative to that approach is inlined functions would
> > take the function name of the parent not keep the
> > inlined function name.
> 
> I tried the following:
> 
> #include <stdio.h>
> 
> inline int foo() {
>   printf("%s %x\n",__func__,0x12345);
> }
> 
> int main () {
>   foo();
> }
> 
> The assembly code generated for main is:
> 
> 0000000000400470 <main>:
>   400470:       b9 45 23 01 00          mov    $0x12345,%ecx
>   400475:       ba 4b 06 40 00          mov    $0x40064b,%edx
>   40047a:       be 44 06 40 00          mov    $0x400644,%esi
>   40047f:       bf 01 00 00 00          mov    $0x1,%edi
>   400484:       31 c0                   xor    %eax,%eax
>   400486:       e9 d5 ff ff ff          jmpq   400460 <__printf_chk@plt>
> 
> That is, the call to foo seems tom be inlined.
> 
> But the output is:
> 
> foo 12345
> 
> So it seems that __func__ is determined before inlining.

True, and that's what I intended to describe.

If you did that with a kernel module and replaced
"%s, __func__" with "%pf, __builtin_return_address(0)"
when built with kallsyms you should get:

"modname 12345" when most would expect "foo 12345"

when built without kallsyms, that output should be
"<address> 12345"

but the object code should be smaller.

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-07 12:30                                                         ` Joe Perches
@ 2014-12-07 12:36                                                           ` Julia Lawall
  2014-12-07 12:42                                                             ` Joe Perches
  0 siblings, 1 reply; 273+ messages in thread
From: Julia Lawall @ 2014-12-07 12:36 UTC (permalink / raw)
  To: Joe Perches
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors



On Sun, 7 Dec 2014, Joe Perches wrote:

> On Sun, 2014-12-07 at 11:44 +0100, Julia Lawall wrote:
> > > A negative to that approach is inlined functions would
> > > take the function name of the parent not keep the
> > > inlined function name.
> > 
> > I tried the following:
> > 
> > #include <stdio.h>
> > 
> > inline int foo() {
> >   printf("%s %x\n",__func__,0x12345);
> > }
> > 
> > int main () {
> >   foo();
> > }
> > 
> > The assembly code generated for main is:
> > 
> > 0000000000400470 <main>:
> >   400470:       b9 45 23 01 00          mov    $0x12345,%ecx
> >   400475:       ba 4b 06 40 00          mov    $0x40064b,%edx
> >   40047a:       be 44 06 40 00          mov    $0x400644,%esi
> >   40047f:       bf 01 00 00 00          mov    $0x1,%edi
> >   400484:       31 c0                   xor    %eax,%eax
> >   400486:       e9 d5 ff ff ff          jmpq   400460 <__printf_chk@plt>
> > 
> > That is, the call to foo seems tom be inlined.
> > 
> > But the output is:
> > 
> > foo 12345
> > 
> > So it seems that __func__ is determined before inlining.
> 
> True, and that's what I intended to describe.
> 
> If you did that with a kernel module and replaced
> "%s, __func__" with "%pf, __builtin_return_address(0)"
> when built with kallsyms you should get:
> 
> "modname 12345" when most would expect "foo 12345"
> 
> when built without kallsyms, that output should be
> "<address> 12345"
> 
> but the object code should be smaller.

OK.  But the semantic patch is only using __func__ and only in cases where 
the string wanted is similar to the name of the current function, so I 
think it should be OK?

julia

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

* Re: [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey()
  2014-12-07 12:36                                                           ` Julia Lawall
@ 2014-12-07 12:42                                                             ` Joe Perches
  0 siblings, 0 replies; 273+ messages in thread
From: Joe Perches @ 2014-12-07 12:42 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Sergei Shtylyov, Paul Mackerras, linux-ppp,
	netdev, Eric Dumazet, LKML, kernel-janitors

On Sun, 2014-12-07 at 13:36 +0100, Julia Lawall wrote:
> the semantic patch is only using __func__ and only in cases where 
> the string wanted is similar to the name of the current function, so I 
> think it should be OK?

Yes, it'd be a good thing.



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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
                                                                 ` (5 preceding siblings ...)
  2014-12-04 22:20                                               ` [PATCH v2 6/6] net-PPP: Delete another " SF Markus Elfring
@ 2014-12-09 19:54                                               ` David Miller
  2014-12-12  7:01                                                 ` SF Markus Elfring
  6 siblings, 1 reply; 273+ messages in thread
From: David Miller @ 2014-12-09 19:54 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 04 Dec 2014 23:03:30 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 4 Dec 2014 22:50:28 +0100
> 
> Further update suggestions were taken into account before and after a patch
> was applied from static source code analysis.

Generally speaking, it is advisable to not leave error pointers in data
structures, even if they are about to be free'd up in an error path
anyways.

Therefore I do not like some of the patches in this series.

Sorry.

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-09 19:54                                               ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks David Miller
@ 2014-12-12  7:01                                                 ` SF Markus Elfring
  2014-12-12 14:29                                                   ` David Miller
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-12  7:01 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

> Generally speaking, it is advisable to not leave error pointers in data
> structures, even if they are about to be free'd up in an error path anyways.
>
> Therefore I do not like some of the patches in this series.

Can you give any more concrete feedback here?

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12  7:01                                                 ` SF Markus Elfring
@ 2014-12-12 14:29                                                   ` David Miller
  2014-12-12 15:30                                                     ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: David Miller @ 2014-12-12 14:29 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 12 Dec 2014 08:01:54 +0100

>> Generally speaking, it is advisable to not leave error pointers in data
>> structures, even if they are about to be free'd up in an error path anyways.
>>
>> Therefore I do not like some of the patches in this series.
> 
> Can you give any more concrete feedback here?

I gave you very concrete feedback, I said exactly that I don't want
error pointers left in data structure members.

I cannot describe my requirements any more precisely than that.

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 14:29                                                   ` David Miller
@ 2014-12-12 15:30                                                     ` SF Markus Elfring
  2014-12-12 15:51                                                       ` David Miller
  2014-12-12 18:46                                                       ` Julia Lawall
  0 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-12 15:30 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

> I gave you very concrete feedback, I said exactly that I don't want
> error pointers left in data structure members.

I find that your critique affects the proposed update steps four to six,
doesn't it?
Are the other steps acceptable in principle?


> I cannot describe my requirements any more precisely than that.

I hope that a bit more constructive suggestions will be contributed by
involved
software developers around the affected source code. Now it seems
that a small code clean-up becomes a more challenging development task.

How do you prefer to redesign corresponding data structures eventually?

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 15:30                                                     ` SF Markus Elfring
@ 2014-12-12 15:51                                                       ` David Miller
  2014-12-12 16:56                                                         ` SF Markus Elfring
  2014-12-12 18:46                                                       ` Julia Lawall
  1 sibling, 1 reply; 273+ messages in thread
From: David Miller @ 2014-12-12 15:51 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall


You are asking me to invest a lot of time for a very trivial
set of changes.

Why don't you just integrate the feedback you were given and
resubmit your patch series, just like any other developer would?

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 15:51                                                       ` David Miller
@ 2014-12-12 16:56                                                         ` SF Markus Elfring
  2014-12-12 16:59                                                           ` David Miller
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-12 16:56 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall


> You are asking me to invest a lot of time for a very trivial
> set of changes.

I find the proposed six update steps also trivial so far.


> Why don't you just integrate the feedback you were given and
> resubmit your patch series, just like any other developer would?

I find the requested redesign and reorganisation of involved data structures
not so easy and therefore more challenging at the moment.
Where should "the error pointers" be stored instead?
Is such a software improvement even a kind of add-on to my patch series?

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 16:56                                                         ` SF Markus Elfring
@ 2014-12-12 16:59                                                           ` David Miller
  2014-12-12 17:22                                                             ` SF Markus Elfring
  2014-12-18 17:23                                                             ` SF Markus Elfring
  0 siblings, 2 replies; 273+ messages in thread
From: David Miller @ 2014-12-12 16:59 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 12 Dec 2014 17:56:36 +0100

> Where should "the error pointers" be stored instead?

A local variable, before you assign it into the datastructure.

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 16:59                                                           ` David Miller
@ 2014-12-12 17:22                                                             ` SF Markus Elfring
  2014-12-12 19:08                                                               ` Eric Dumazet
  2014-12-12 20:07                                                               ` David Miller
  2014-12-18 17:23                                                             ` SF Markus Elfring
  1 sibling, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-12 17:22 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

>> Where should "the error pointers" be stored instead?
> A local variable, before you assign it into the datastructure.

Will it be acceptable for you that anyone (or even me) will introduce
such a change with a seventh (and eventually eighth) update step here?
Do you want any other sequence for source code preparation of
the requested software improvement?

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 15:30                                                     ` SF Markus Elfring
  2014-12-12 15:51                                                       ` David Miller
@ 2014-12-12 18:46                                                       ` Julia Lawall
  1 sibling, 0 replies; 273+ messages in thread
From: Julia Lawall @ 2014-12-12 18:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Miller, Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev,
	Eric Dumazet, linux-kernel, kernel-janitors, Julia Lawall

> I hope that a bit more constructive suggestions will be contributed by
> involved
> software developers around the affected source code. Now it seems
> that a small code clean-up becomes a more challenging development task.

This is often the case.  Doing something half way is not useful.

julia

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 17:22                                                             ` SF Markus Elfring
@ 2014-12-12 19:08                                                               ` Eric Dumazet
  2014-12-13  6:05                                                                 ` SF Markus Elfring
  2014-12-12 20:07                                                               ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: Eric Dumazet @ 2014-12-12 19:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Miller, Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

On Fri, 2014-12-12 at 18:22 +0100, SF Markus Elfring wrote:

> Will it be acceptable for you that anyone (or even me) will introduce
> such a change with a seventh (and eventually eighth) update step here?
> Do you want any other sequence for source code preparation of
> the requested software improvement?

The thing is : We are in the merge window, tracking bugs added in latest
dev cycle.

Having to deal with patches like yours is adding pressure
on the maintainer (and other developers) at the wrong time.





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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 17:22                                                             ` SF Markus Elfring
  2014-12-12 19:08                                                               ` Eric Dumazet
@ 2014-12-12 20:07                                                               ` David Miller
  2014-12-13  6:17                                                                 ` SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: David Miller @ 2014-12-12 20:07 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 12 Dec 2014 18:22:48 +0100

>>> Where should "the error pointers" be stored instead?
>> A local variable, before you assign it into the datastructure.
> 
> Will it be acceptable for you that anyone (or even me) will introduce
> such a change with a seventh (and eventually eighth) update step here?
> Do you want any other sequence for source code preparation of
> the requested software improvement?

I'd like to honestly ask why you are being so difficult?

Everyone gets their code reviewed, everyone has to modify their
changes to adhere to the subsystem maintainer's wishes.  You
are not being treated specially, and quite frankly nobody is
asking anything unreasonable of you.

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 19:08                                                               ` Eric Dumazet
@ 2014-12-13  6:05                                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-13  6:05 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev,
	linux-kernel, kernel-janitors, Julia Lawall

> We are in the merge window, tracking bugs added in latest dev cycle.

I am also curious on the software evolution about how many improvements will
arrive in the next Linux versions.


> Having to deal with patches like yours is adding pressure
> on the maintainer (and other developers) at the wrong time.

You can relax a bit eventually. More merge windows will follow, won't they?

It will be nice if a bunch of recent code clean-ups which were also
triggered
by static source code analysis will be integrated into Linux 3.19 already.
More update suggestions will be considered later again as usual.

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 20:07                                                               ` David Miller
@ 2014-12-13  6:17                                                                 ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-13  6:17 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

> I'd like to honestly ask why you are being so difficult?

There are several factors which contribute to your perception of
difficulty here.

1. I try to extract from every feedback the information about the amount
of acceptance or rejection for a specific update suggestion.
   A terse feedback (like yours for this issue) makes it occasionally
harder to see the next useful steps. So another constructive discussion
is evolving around the clarification of some implementation details.

2. I prefer also different communication styles at some points.

3. I reached a point where the desired software updates were not
immediately obvious for me while other contributors might have achieved
a better understanding for the affected issues already.

4. I am on the way at the moment to get my Linux software development
system running again.
  
https://forums.opensuse.org/showthread.php/503327-System-startup-does-not-continue-after-hard-disk-detection


> Everyone gets their code reviewed, everyone has to modify their
> changes to adhere to the subsystem maintainer's wishes.

That is fine as usual.


> You are not being treated specially, and quite frankly nobody
> is asking anything unreasonable of you.

That is also true as the software development process will be continued.

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-12 16:59                                                           ` David Miller
  2014-12-12 17:22                                                             ` SF Markus Elfring
@ 2014-12-18 17:23                                                             ` SF Markus Elfring
  2014-12-18 17:25                                                               ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-18 17:23 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

>> Where should "the error pointers" be stored instead?
> 
> A local variable, before you assign it into the datastructure.

I have looked at the affected software infrastructure once more.
Now I find still that your data reorgansisation wish can not be resolved
in a simple way.

I imagine that your update suggestion would mean that the corresponding
pointers will be passed around by function parameters instead,
wouldn't it?

Two pointers were stored as the members "arc4" and "sha1" of the
data structure "ppp_mppe_state" for a specific reason. A pointer to
this structure is passed to the ppp_register_compressor() function.
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/include/linux/ppp-comp.h?id=607ca46e97a1b6594b29647d98a32d545c24bdff#n32

The data structure "compressor" manages some function pointers.
I assume that this interface should not be changed at the moment, should it?

Are further ideas needed here?

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-18 17:23                                                             ` SF Markus Elfring
@ 2014-12-18 17:25                                                               ` David Miller
  2014-12-18 17:44                                                                 ` SF Markus Elfring
  2014-12-20 14:45                                                                 ` SF Markus Elfring
  0 siblings, 2 replies; 273+ messages in thread
From: David Miller @ 2014-12-18 17:25 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 18 Dec 2014 18:23:08 +0100

>>> Where should "the error pointers" be stored instead?
>> 
>> A local variable, before you assign it into the datastructure.
> 
> I have looked at the affected software infrastructure once more.
> Now I find still that your data reorgansisation wish can not be resolved
> in a simple way.

I'm saying to leave the code alone.

If it goes:

	var = foo_that_returns_ptr_err()
	if (IS_ERR(var))
		return PTR_ERR(var);

	p->bar = var;

or whatever, simply keep it that way!

I'm not engaging in this conversation any further, you have already
consumed way too much of my limited time on this incredibly trivial
matter.

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-18 17:25                                                               ` David Miller
@ 2014-12-18 17:44                                                                 ` SF Markus Elfring
  2014-12-20 14:45                                                                 ` SF Markus Elfring
  1 sibling, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-18 17:44 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

>> Now I find still that your data reorgansisation wish can not be resolved
>> in a simple way.
> 
> I'm saying to leave the code alone.

It seems that there might be a misunderstanding between us.


> If it goes:
> 
> 	var = foo_that_returns_ptr_err()
> 	if (IS_ERR(var))
> 		return PTR_ERR(var);
> 
> 	p->bar = var;
> 
> or whatever, simply keep it that way!

A simple return was not used by the mppe_alloc() function so far because
a bit of memory clean-up will also be useful after error detection,
won't it?


> I'm not engaging in this conversation any further, you have already
> consumed way too much of my limited time on this incredibly trivial matter.

It can occasionally happen that a safe clarification of specific implementation
details will need more efforts than you would like to invest at the moment.

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-18 17:25                                                               ` David Miller
  2014-12-18 17:44                                                                 ` SF Markus Elfring
@ 2014-12-20 14:45                                                                 ` SF Markus Elfring
  2014-12-20 15:48                                                                   ` Lino Sanfilippo
  2014-12-20 19:30                                                                   ` David Miller
  1 sibling, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-20 14:45 UTC (permalink / raw)
  To: David Miller
  Cc: Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev, Eric Dumazet,
	linux-kernel, kernel-janitors, Julia Lawall

> I'm saying to leave the code alone.

Do I need to try another interpretation out for your feedback?


> If it goes:
> 
> 	var = foo_that_returns_ptr_err()
> 	if (IS_ERR(var))
> 		return PTR_ERR(var);
> 
> 	p->bar = var;
> 
> or whatever, simply keep it that way!

Do you want to express here that a data structure member should
only be set after a previous function call succeeded?



> I'm not engaging in this conversation any further, you have
> already consumed way too much of my limited time on this
> incredibly trivial matter.

I hope that you will find a bit time and patience again
to clarify affected implementation details in a safer and
unambiguous way.

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-20 14:45                                                                 ` SF Markus Elfring
@ 2014-12-20 15:48                                                                   ` Lino Sanfilippo
  2014-12-20 16:17                                                                     ` SF Markus Elfring
  2014-12-20 19:30                                                                   ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: Lino Sanfilippo @ 2014-12-20 15:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Miller, Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev,
	Eric Dumazet, linux-kernel, kernel-janitors, Julia Lawall

Hi Markus,

On 20.12.2014 15:45, SF Markus Elfring wrote:
>> I'm saying to leave the code alone.
> 
> Do I need to try another interpretation out for your feedback?
> 
> 
>> If it goes:
>> 
>> 	var = foo_that_returns_ptr_err()
>> 	if (IS_ERR(var))
>> 		return PTR_ERR(var);
>> 
>> 	p->bar = var;
>> 
>> or whatever, simply keep it that way!
> 
> Do you want to express here that a data structure member should
> only be set after a previous function call succeeded?
> 

I think what David said was pretty clear: If you see code like the above
there is no need to refactor it. That does not mean that this is the
_preferred_ way of error handling. Its just good enough to be left alone.

Regards,
Lino

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-20 15:48                                                                   ` Lino Sanfilippo
@ 2014-12-20 16:17                                                                     ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2014-12-20 16:17 UTC (permalink / raw)
  To: Lino Sanfilippo
  Cc: David Miller, Sergei Shtylyov, Paul Mackerras, linux-ppp, netdev,
	Eric Dumazet, linux-kernel, kernel-janitors, Julia Lawall

> I think what David said was pretty clear: If you see code like the above
> there is no need to refactor it.

I can understand this view in principle.


> That does not mean that this is the _preferred_ way of error handling.

Can your feedback help in the clarification of suggestions around
my update steps one to six for this Linux software module?

Regards,
Markus

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

* Re: [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks
  2014-12-20 14:45                                                                 ` SF Markus Elfring
  2014-12-20 15:48                                                                   ` Lino Sanfilippo
@ 2014-12-20 19:30                                                                   ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2014-12-20 19:30 UTC (permalink / raw)
  To: elfring
  Cc: sergei.shtylyov, paulus, linux-ppp, netdev, eric.dumazet,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Dec 2014 15:45:32 +0100

> I hope that you will find a bit time and patience again
> to clarify affected implementation details in a safer and
> unambiguous way.

Sorry, another developer will have to hold your hand, as I
said I already invested too much time into this.

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

* [PATCH] net: sched: One function call less in em_meta_change() after error detection
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (14 preceding siblings ...)
  2014-11-30 16:40                                   ` [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-01-31 16:34                                   ` SF Markus Elfring
  2015-01-31 17:31                                     ` Lino Sanfilippo
                                                       ` (2 more replies)
  2015-01-31 17:15                                   ` [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
                                                     ` (38 subsequent siblings)
  54 siblings, 3 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 16:34 UTC (permalink / raw)
  To: David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 17:18:48 +0100

The meta_delete() function could be called in four cases by the
em_meta_change() function during error handling even if the passed
variable "meta" contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to
  the current Linux coding style convention.

* Let us delete also unnecessary checks for the variables "err" and
  "meta" there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sched/em_meta.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index b5294ce..2aa67b1 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -866,23 +866,23 @@ static int em_meta_change(struct net *net, void *data, int len,
 
 	err = nla_parse(tb, TCA_EM_META_MAX, data, len, meta_policy);
 	if (err < 0)
-		goto errout;
+		return err;
 
 	err = -EINVAL;
 	if (tb[TCA_EM_META_HDR] == NULL)
-		goto errout;
+		goto exit;
 	hdr = nla_data(tb[TCA_EM_META_HDR]);
 
 	if (TCF_META_TYPE(hdr->left.kind) != TCF_META_TYPE(hdr->right.kind) ||
 	    TCF_META_TYPE(hdr->left.kind) > TCF_META_TYPE_MAX ||
 	    TCF_META_ID(hdr->left.kind) > TCF_META_ID_MAX ||
 	    TCF_META_ID(hdr->right.kind) > TCF_META_ID_MAX)
-		goto errout;
+		goto exit;
 
 	meta = kzalloc(sizeof(*meta), GFP_KERNEL);
 	if (meta == NULL) {
 		err = -ENOMEM;
-		goto errout;
+		goto exit;
 	}
 
 	memcpy(&meta->lvalue.hdr, &hdr->left, sizeof(hdr->left));
@@ -891,20 +891,20 @@ static int em_meta_change(struct net *net, void *data, int len,
 	if (!meta_is_supported(&meta->lvalue) ||
 	    !meta_is_supported(&meta->rvalue)) {
 		err = -EOPNOTSUPP;
-		goto errout;
+		goto delete_meta;
 	}
 
 	if (meta_change_data(&meta->lvalue, tb[TCA_EM_META_LVALUE]) < 0 ||
 	    meta_change_data(&meta->rvalue, tb[TCA_EM_META_RVALUE]) < 0)
-		goto errout;
+		goto delete_meta;
 
 	m->datalen = sizeof(*meta);
 	m->data = (unsigned long) meta;
 
-	err = 0;
-errout:
-	if (err && meta)
-		meta_delete(meta);
+	return 0;
+delete_meta:
+	meta_delete(meta);
+exit:
 	return err;
 }
 
-- 
2.2.2

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

* [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (15 preceding siblings ...)
  2015-01-31 16:34                                   ` [PATCH] net: sched: One function call less in em_meta_change() after error detection SF Markus Elfring
@ 2015-01-31 17:15                                   ` SF Markus Elfring
  2015-01-31 18:38                                     ` Neil Horman
  2015-02-03  3:30                                     ` David Miller
  2015-01-31 21:14                                   ` [PATCH 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
                                                     ` (37 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 17:15 UTC (permalink / raw)
  To: David S. Miller, Neil Horman, Vlad Yasevich, linux-sctp, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 18:10:03 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sctp/associola.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index f791edd..3c2aefc 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -391,8 +391,7 @@ void sctp_association_free(struct sctp_association *asoc)
 	sctp_asconf_queue_teardown(asoc);
 
 	/* Free pending address space being deleted */
-	if (asoc->asconf_addr_del_pending != NULL)
-		kfree(asoc->asconf_addr_del_pending);
+	kfree(asoc->asconf_addr_del_pending);
 
 	/* AUTH - Free the endpoint shared keys */
 	sctp_auth_destroy_keys(&asoc->endpoint_shared_keys);
-- 
2.2.2

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 16:34                                   ` [PATCH] net: sched: One function call less in em_meta_change() after error detection SF Markus Elfring
@ 2015-01-31 17:31                                     ` Lino Sanfilippo
  2015-01-31 21:48                                       ` SF Markus Elfring
  2015-01-31 17:50                                     ` Lino Sanfilippo
  2015-02-04  0:10                                     ` David Miller
  2 siblings, 1 reply; 273+ messages in thread
From: Lino Sanfilippo @ 2015-01-31 17:31 UTC (permalink / raw)
  To: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

Hi,

On 31.01.2015 17:34, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 17:18:48 +0100
> 
> The meta_delete() function could be called in four cases by the
> em_meta_change() function during error handling even if the passed
> variable "meta" contained still a null pointer.
> 
> * This implementation detail could be improved by adjustments for jump labels.
> 
> * Let us return immediately after the first failed function call according to
>   the current Linux coding style convention.
> 
> * Let us delete also unnecessary checks for the variables "err" and
>   "meta" there.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/sched/em_meta.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
> index b5294ce..2aa67b1 100644
> --- a/net/sched/em_meta.c
> +++ b/net/sched/em_meta.c
> @@ -866,23 +866,23 @@ static int em_meta_change(struct net *net, void *data, int len,
>  
>  	err = nla_parse(tb, TCA_EM_META_MAX, data, len, meta_policy);
>  	if (err < 0)
> -		goto errout;
> +		return err;
>  
>  	err = -EINVAL;
>  	if (tb[TCA_EM_META_HDR] == NULL)
> -		goto errout;
> +		goto exit;
>  	hdr = nla_data(tb[TCA_EM_META_HDR]);
>  
>  	if (TCF_META_TYPE(hdr->left.kind) != TCF_META_TYPE(hdr->right.kind) ||
>  	    TCF_META_TYPE(hdr->left.kind) > TCF_META_TYPE_MAX ||
>  	    TCF_META_ID(hdr->left.kind) > TCF_META_ID_MAX ||
>  	    TCF_META_ID(hdr->right.kind) > TCF_META_ID_MAX)
> -		goto errout;
> +		goto exit;
>  
>  	meta = kzalloc(sizeof(*meta), GFP_KERNEL);
>  	if (meta == NULL) {
>  		err = -ENOMEM;
> -		goto errout;
> +		goto exit;
>  	}
>  
>  	memcpy(&meta->lvalue.hdr, &hdr->left, sizeof(hdr->left));
> @@ -891,20 +891,20 @@ static int em_meta_change(struct net *net, void *data, int len,
>  	if (!meta_is_supported(&meta->lvalue) ||
>  	    !meta_is_supported(&meta->rvalue)) {
>  		err = -EOPNOTSUPP;
> -		goto errout;
> +		goto delete_meta;
>  	}
>  
>  	if (meta_change_data(&meta->lvalue, tb[TCA_EM_META_LVALUE]) < 0 ||
>  	    meta_change_data(&meta->rvalue, tb[TCA_EM_META_RVALUE]) < 0)
> -		goto errout;
> +		goto delete_meta;
>  
>  	m->datalen = sizeof(*meta);
>  	m->data = (unsigned long) meta;
>  
> -	err = 0;
> -errout:
> -	if (err && meta)
> -		meta_delete(meta);
> +	return 0;
> +delete_meta:
> +	meta_delete(meta);
> +exit:
>  	return err;
>  }

Why do you use that exit label if it does nothing more than returning
the error value? Also if nla_parse fails you dont use it but return the
error directly. While using a label which is used only to return an
error may be a matter of taste, its at least inconsistent to do both in
a function, use such a label in one case and return immediately in
another, isnt it?

Regards,
Lino



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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 16:34                                   ` [PATCH] net: sched: One function call less in em_meta_change() after error detection SF Markus Elfring
  2015-01-31 17:31                                     ` Lino Sanfilippo
@ 2015-01-31 17:50                                     ` Lino Sanfilippo
  2015-01-31 21:52                                       ` SF Markus Elfring
  2015-02-04  0:10                                     ` David Miller
  2 siblings, 1 reply; 273+ messages in thread
From: Lino Sanfilippo @ 2015-01-31 17:50 UTC (permalink / raw)
  To: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 31.01.2015 17:34, SF Markus Elfring wrote:

> -errout:
> -	if (err && meta)
> -		meta_delete(meta);

Since this patch seems to be about optimization and cleanup you should
probably also remove the now unnecessary initialization of "meta" with
NULL at the beginning of the function...

Regards,
Lino

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

* Re: [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree"
  2015-01-31 17:15                                   ` [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-01-31 18:38                                     ` Neil Horman
  2015-02-03  3:30                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: Neil Horman @ 2015-01-31 18:38 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Vlad Yasevich, linux-sctp, netdev, LKML,
	kernel-janitors, Julia Lawall

On Sat, Jan 31, 2015 at 06:15:59PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 18:10:03 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/sctp/associola.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/sctp/associola.c b/net/sctp/associola.c
> index f791edd..3c2aefc 100644
> --- a/net/sctp/associola.c
> +++ b/net/sctp/associola.c
> @@ -391,8 +391,7 @@ void sctp_association_free(struct sctp_association *asoc)
>  	sctp_asconf_queue_teardown(asoc);
>  
>  	/* Free pending address space being deleted */
> -	if (asoc->asconf_addr_del_pending != NULL)
> -		kfree(asoc->asconf_addr_del_pending);
> +	kfree(asoc->asconf_addr_del_pending);
>  
>  	/* AUTH - Free the endpoint shared keys */
>  	sctp_auth_destroy_keys(&asoc->endpoint_shared_keys);
> -- 
> 2.2.2
> 
> 
Sure, seems reasonable
Acked-By: Neil Horman <nhorman@tuxdriver.com>

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

* [PATCH 0/3] netlabel: Deletion of a few unnecessary checks
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (16 preceding siblings ...)
  2015-01-31 17:15                                   ` [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-01-31 21:14                                   ` SF Markus Elfring
  2015-01-31 21:34                                     ` [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
                                                       ` (2 more replies)
  2015-02-03 18:51                                   ` [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put" SF Markus Elfring
                                                     ` (36 subsequent siblings)
  54 siblings, 3 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 21:14 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 22:00:14 +0100

Further update suggestions were taken into account after patches were applied
from static source code analysis.

Markus Elfring (3):
  Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
  Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
  Less function calls in netlbl_mgmt_add_common() after error detection

 net/netlabel/netlabel_cipso_v4.c |  3 +--
 net/netlabel/netlabel_mgmt.c     | 47 ++++++++++++++++++++--------------------
 2 files changed, 24 insertions(+), 26 deletions(-)

-- 
2.2.2

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

* [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
  2015-01-31 21:14                                   ` [PATCH 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-01-31 21:34                                     ` SF Markus Elfring
  2015-02-01  2:20                                       ` Paul Moore
  2015-01-31 21:36                                     ` [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
  2015-01-31 21:38                                     ` [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 21:34 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 19:09:50 +0100

The cipso_v4_doi_putdef() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlabel/netlabel_mgmt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 8b3b789..f5807f5 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -242,8 +242,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 	return 0;
 
 add_failure:
-	if (cipsov4)
-		cipso_v4_doi_putdef(cipsov4);
+	cipso_v4_doi_putdef(cipsov4);
 	if (entry)
 		kfree(entry->domain);
 	kfree(addrmap);
-- 
2.2.2


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

* [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
  2015-01-31 21:14                                   ` [PATCH 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
  2015-01-31 21:34                                     ` [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
@ 2015-01-31 21:36                                     ` SF Markus Elfring
  2015-02-01  2:22                                       ` Paul Moore
  2015-01-31 21:38                                     ` [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 21:36 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 19:35:59 +0100

The cipso_v4_doi_free() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlabel/netlabel_cipso_v4.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index 1796253..7fd1104 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -324,8 +324,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
 	return 0;
 
 add_std_failure:
-	if (doi_def)
-		cipso_v4_doi_free(doi_def);
+	cipso_v4_doi_free(doi_def);
 	return ret_val;
 }
 
-- 
2.2.2


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

* [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
  2015-01-31 21:14                                   ` [PATCH 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
  2015-01-31 21:34                                     ` [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
  2015-01-31 21:36                                     ` [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
@ 2015-01-31 21:38                                     ` SF Markus Elfring
  2015-02-01  2:40                                       ` Paul Moore
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 21:38 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 21:55:48 +0100

The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases
by the netlbl_mgmt_add_common() function during error handling even if the
passed variables contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to
  the current Linux coding style convention.

* Let us delete also an unnecessary check for the variable "entry" there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlabel/netlabel_mgmt.c | 46 ++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index f5807f5..17f1ed5 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -99,17 +99,15 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 	u32 tmp_val;
 
 	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
-	if (entry == NULL) {
-		ret_val = -ENOMEM;
-		goto add_failure;
-	}
+	if (!entry)
+		return -ENOMEM;
 	entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
 	if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
 		size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
 		entry->domain = kmalloc(tmp_size, GFP_KERNEL);
 		if (entry->domain == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto free_entry;
 		}
 		nla_strlcpy(entry->domain,
 			    info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
@@ -125,16 +123,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		break;
 	case NETLBL_NLTYPE_CIPSOV4:
 		if (!info->attrs[NLBL_MGMT_A_CV4DOI])
-			goto add_failure;
+			goto free_domain;
 
 		tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
 		cipsov4 = cipso_v4_doi_getdef(tmp_val);
 		if (cipsov4 == NULL)
-			goto add_failure;
+			goto free_domain;
 		entry->def.cipso = cipsov4;
 		break;
 	default:
-		goto add_failure;
+		goto free_domain;
 	}
 
 	if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) {
@@ -145,7 +143,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
 		if (addrmap == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto doi_put_def;
 		}
 		INIT_LIST_HEAD(&addrmap->list4);
 		INIT_LIST_HEAD(&addrmap->list6);
@@ -153,12 +151,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !=
 		    sizeof(struct in_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto free_address_map;
 		}
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !=
 		    sizeof(struct in_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto free_address_map;
 		}
 		addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
 		mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
@@ -166,7 +164,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (map == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto free_address_map;
 		}
 		map->list.addr = addr->s_addr & mask->s_addr;
 		map->list.mask = mask->s_addr;
@@ -178,7 +176,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
 		if (ret_val != 0) {
 			kfree(map);
-			goto add_failure;
+			goto free_address_map;
 		}
 
 		entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
@@ -192,7 +190,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
 		if (addrmap == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto doi_put_def;
 		}
 		INIT_LIST_HEAD(&addrmap->list4);
 		INIT_LIST_HEAD(&addrmap->list6);
@@ -200,12 +198,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !=
 		    sizeof(struct in6_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto free_address_map;
 		}
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !=
 		    sizeof(struct in6_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto free_address_map;
 		}
 		addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
 		mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
@@ -213,7 +211,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (map == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto free_address_map;
 		}
 		map->list.addr = *addr;
 		map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
@@ -227,7 +225,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
 		if (ret_val != 0) {
 			kfree(map);
-			goto add_failure;
+			goto free_address_map;
 		}
 
 		entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
@@ -237,15 +235,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 
 	ret_val = netlbl_domhsh_add(entry, audit_info);
 	if (ret_val != 0)
-		goto add_failure;
+		goto free_address_map;
 
 	return 0;
 
-add_failure:
-	cipso_v4_doi_putdef(cipsov4);
-	if (entry)
-		kfree(entry->domain);
+free_address_map:
 	kfree(addrmap);
+doi_put_def:
+	cipso_v4_doi_putdef(cipsov4);
+free_domain:
+	kfree(entry->domain);
+free_entry:
 	kfree(entry);
 	return ret_val;
 }
-- 
2.2.2

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 17:31                                     ` Lino Sanfilippo
@ 2015-01-31 21:48                                       ` SF Markus Elfring
  2015-01-31 22:15                                         ` Lino Sanfilippo
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 21:48 UTC (permalink / raw)
  To: Lino Sanfilippo, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

>> +exit:
>>  	return err;
>>  }
> 
> Why do you use that exit label if it does nothing more than returning
> the error value? Also if nla_parse fails you dont use it but return the
> error directly. While using a label which is used only to return an
> error may be a matter of taste, its at least inconsistent to do both in
> a function, use such a label in one case and return immediately in
> another, isnt it?

I find that all these cases correspond to the current Linux coding
style documentation, doesn't it?

Regards,
Markus

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 17:50                                     ` Lino Sanfilippo
@ 2015-01-31 21:52                                       ` SF Markus Elfring
  2015-01-31 22:09                                         ` Lino Sanfilippo
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 21:52 UTC (permalink / raw)
  To: Lino Sanfilippo, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

>> -errout:
>> -	if (err && meta)
>> -		meta_delete(meta);
> 
> Since this patch seems to be about optimization and cleanup you should
> probably also remove the now unnecessary initialization of "meta" with
> NULL at the beginning of the function...

Will the optimiser of the C compiler drop any remaining unnecessary
variable initialisations?

Do you want another update step here?

Regards,
Markus

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 21:52                                       ` SF Markus Elfring
@ 2015-01-31 22:09                                         ` Lino Sanfilippo
  0 siblings, 0 replies; 273+ messages in thread
From: Lino Sanfilippo @ 2015-01-31 22:09 UTC (permalink / raw)
  To: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 31.01.2015 22:52, SF Markus Elfring wrote:
>>> -errout:
>>> -	if (err && meta)
>>> -		meta_delete(meta);
>> 
>> Since this patch seems to be about optimization and cleanup you should
>> probably also remove the now unnecessary initialization of "meta" with
>> NULL at the beginning of the function...
> 
> Will the optimiser of the C compiler drop any remaining unnecessary
> variable initialisations?
> 

I dont know if that matters, since the code is not only used by
compilers but also read by humans.

> Do you want another update step here?
> 

I am not the one who decides if this patch is acceptable or not. But I
vote for a removal of that assignment (as a part of the same patch).

Regards,
Lino

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 21:48                                       ` SF Markus Elfring
@ 2015-01-31 22:15                                         ` Lino Sanfilippo
  2015-01-31 22:20                                           ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Lino Sanfilippo @ 2015-01-31 22:15 UTC (permalink / raw)
  To: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 31.01.2015 22:48, SF Markus Elfring wrote:

> 
> I find that all these cases correspond to the current Linux coding
> style documentation, doesn't it?
> 

Sure, I think it does. But it was not coding style violation what I was
reffering to.

Regards,
Lino

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 22:15                                         ` Lino Sanfilippo
@ 2015-01-31 22:20                                           ` SF Markus Elfring
  2015-01-31 22:51                                             ` Lino Sanfilippo
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-01-31 22:20 UTC (permalink / raw)
  To: Lino Sanfilippo, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

>> I find that all these cases correspond to the current Linux coding
>> style documentation, doesn't it?
> 
> Sure, I think it does.

Thanks for your acknowledgement.


> But it was not coding style violation what I was reffering to.

Do you suggest any fine-tuning for the affected documentation
so that I would tweak my update suggestion once more?

Regards,
Markus

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 22:20                                           ` SF Markus Elfring
@ 2015-01-31 22:51                                             ` Lino Sanfilippo
  0 siblings, 0 replies; 273+ messages in thread
From: Lino Sanfilippo @ 2015-01-31 22:51 UTC (permalink / raw)
  To: SF Markus Elfring, David S. Miller, Jamal Hadi Salim, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 31.01.2015 23:20, SF Markus Elfring wrote:
>>> I find that all these cases correspond to the current Linux coding
>>> style documentation, doesn't it?
>> 
>> Sure, I think it does.
> 
> Thanks for your acknowledgement.
> 
> 
>> But it was not coding style violation what I was reffering to.
> 
> Do you suggest any fine-tuning for the affected documentation
> so that I would tweak my update suggestion once more?
> 

No I dont think that any documentation has to be adjusted. If you agree
with me you should adjust the patch accordingly and resend it. Otherwise
keep it as it is.

Regards,
Lino

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

* Re: [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
  2015-01-31 21:34                                     ` [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
@ 2015-02-01  2:20                                       ` Paul Moore
  0 siblings, 0 replies; 273+ messages in thread
From: Paul Moore @ 2015-02-01  2:20 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, netdev, LKML, kernel-janitors, Julia Lawall

On Sat, Jan 31, 2015 at 4:34 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 19:09:50 +0100
>
> The cipso_v4_doi_putdef() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netlabel/netlabel_mgmt.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Acked-by: Paul Moore <paul@paul-moore.com>

> diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
> index 8b3b789..f5807f5 100644
> --- a/net/netlabel/netlabel_mgmt.c
> +++ b/net/netlabel/netlabel_mgmt.c
> @@ -242,8 +242,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>         return 0;
>
>  add_failure:
> -       if (cipsov4)
> -               cipso_v4_doi_putdef(cipsov4);
> +       cipso_v4_doi_putdef(cipsov4);
>         if (entry)
>                 kfree(entry->domain);
>         kfree(addrmap);
> --
> 2.2.2
>



-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
  2015-01-31 21:36                                     ` [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
@ 2015-02-01  2:22                                       ` Paul Moore
  0 siblings, 0 replies; 273+ messages in thread
From: Paul Moore @ 2015-02-01  2:22 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, netdev, LKML, kernel-janitors, Julia Lawall

On Sat, Jan 31, 2015 at 4:36 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 19:35:59 +0100
>
> The cipso_v4_doi_free() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netlabel/netlabel_cipso_v4.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Acked-by: Paul Moore <paul@paul-moore.com>

> diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
> index 1796253..7fd1104 100644
> --- a/net/netlabel/netlabel_cipso_v4.c
> +++ b/net/netlabel/netlabel_cipso_v4.c
> @@ -324,8 +324,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
>         return 0;
>
>  add_std_failure:
> -       if (doi_def)
> -               cipso_v4_doi_free(doi_def);
> +       cipso_v4_doi_free(doi_def);
>         return ret_val;
>  }
>
> --
> 2.2.2
>



-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
  2015-01-31 21:38                                     ` [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
@ 2015-02-01  2:40                                       ` Paul Moore
  2015-02-01 10:15                                         ` [PATCH v2 " SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Paul Moore @ 2015-02-01  2:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, netdev, LKML, kernel-janitors, Julia Lawall

On Sat, Jan 31, 2015 at 4:38 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 21:55:48 +0100
>
> The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases
> by the netlbl_mgmt_add_common() function during error handling even if the
> passed variables contained still a null pointer.
>
> * This implementation detail could be improved by adjustments for jump labels.
>
> * Let us return immediately after the first failed function call according to
>   the current Linux coding style convention.
>
> * Let us delete also an unnecessary check for the variable "entry" there.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netlabel/netlabel_mgmt.c | 46 ++++++++++++++++++++++----------------------
>  1 file changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
> index f5807f5..17f1ed5 100644
> --- a/net/netlabel/netlabel_mgmt.c
> +++ b/net/netlabel/netlabel_mgmt.c

...

> @@ -237,15 +235,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>
>         ret_val = netlbl_domhsh_add(entry, audit_info);
>         if (ret_val != 0)
> -               goto add_failure;
> +               goto free_address_map;
>
>         return 0;
>
> -add_failure:
> -       cipso_v4_doi_putdef(cipsov4);
> -       if (entry)
> -               kfree(entry->domain);
> +free_address_map:
>         kfree(addrmap);
> +doi_put_def:
> +       cipso_v4_doi_putdef(cipsov4);
> +free_domain:
> +       kfree(entry->domain);
> +free_entry:
>         kfree(entry);
>         return ret_val;
>  }

It would be nice if you could stick with the goto label naming style
in the rest of the file, e.g.
"add_free_addrmap"/"add_put_doi_def"/"add_free_domain"/"add_free_entry".

-- 
paul moore
www.paul-moore.com

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

* [PATCH v2 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
  2015-02-01  2:40                                       ` Paul Moore
@ 2015-02-01 10:15                                         ` SF Markus Elfring
  2015-02-01 14:39                                           ` Paul Moore
  2015-02-01 20:30                                           ` David Miller
  0 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-01 10:15 UTC (permalink / raw)
  To: Paul Moore; +Cc: David S. Miller, netdev, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 1 Feb 2015 11:11:29 +0100

The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases
by the netlbl_mgmt_add_common() function during error handling even if the
passed variables contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to
  the current Linux coding style convention.

* Let us delete also an unnecessary check for the variable "entry" there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlabel/netlabel_mgmt.c | 49 ++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index f5807f5..7044074 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 				  struct netlbl_audit *audit_info)
 {
 	int ret_val = -EINVAL;
-	struct netlbl_dom_map *entry = NULL;
 	struct netlbl_domaddr_map *addrmap = NULL;
 	struct cipso_v4_doi *cipsov4 = NULL;
 	u32 tmp_val;
+	struct netlbl_dom_map *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
 
-	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
-	if (entry == NULL) {
-		ret_val = -ENOMEM;
-		goto add_failure;
-	}
+	if (!entry)
+		return -ENOMEM;
 	entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
 	if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
 		size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
 		entry->domain = kmalloc(tmp_size, GFP_KERNEL);
 		if (entry->domain == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_free_entry;
 		}
 		nla_strlcpy(entry->domain,
 			    info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		break;
 	case NETLBL_NLTYPE_CIPSOV4:
 		if (!info->attrs[NLBL_MGMT_A_CV4DOI])
-			goto add_failure;
+			goto add_free_domain;
 
 		tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
 		cipsov4 = cipso_v4_doi_getdef(tmp_val);
 		if (cipsov4 == NULL)
-			goto add_failure;
+			goto add_free_domain;
 		entry->def.cipso = cipsov4;
 		break;
 	default:
-		goto add_failure;
+		goto add_free_domain;
 	}
 
 	if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) {
@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
 		if (addrmap == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_doi_put_def;
 		}
 		INIT_LIST_HEAD(&addrmap->list4);
 		INIT_LIST_HEAD(&addrmap->list6);
@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !=
 		    sizeof(struct in_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !=
 		    sizeof(struct in_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
 		mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (map == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		map->list.addr = addr->s_addr & mask->s_addr;
 		map->list.mask = mask->s_addr;
@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
 		if (ret_val != 0) {
 			kfree(map);
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 
 		entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
 		if (addrmap == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_doi_put_def;
 		}
 		INIT_LIST_HEAD(&addrmap->list4);
 		INIT_LIST_HEAD(&addrmap->list6);
@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !=
 		    sizeof(struct in6_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !=
 		    sizeof(struct in6_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
 		mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (map == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		map->list.addr = *addr;
 		map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
 		if (ret_val != 0) {
 			kfree(map);
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 
 		entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
@@ -237,15 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 
 	ret_val = netlbl_domhsh_add(entry, audit_info);
 	if (ret_val != 0)
-		goto add_failure;
+		goto add_free_addrmap;
 
 	return 0;
 
-add_failure:
-	cipso_v4_doi_putdef(cipsov4);
-	if (entry)
-		kfree(entry->domain);
+add_free_addrmap:
 	kfree(addrmap);
+add_doi_put_def:
+	cipso_v4_doi_putdef(cipsov4);
+add_free_domain:
+	kfree(entry->domain);
+add_free_entry:
 	kfree(entry);
 	return ret_val;
 }
-- 
2.2.2

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

* Re: [PATCH v2 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
  2015-02-01 10:15                                         ` [PATCH v2 " SF Markus Elfring
@ 2015-02-01 14:39                                           ` Paul Moore
  2015-02-01 20:30                                           ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: Paul Moore @ 2015-02-01 14:39 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, netdev, LKML, kernel-janitors, Julia Lawall

On Sun, Feb 1, 2015 at 5:15 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 1 Feb 2015 11:11:29 +0100
>
> The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases
> by the netlbl_mgmt_add_common() function during error handling even if the
> passed variables contained still a null pointer.
>
> * This implementation detail could be improved by adjustments for jump labels.
>
> * Let us return immediately after the first failed function call according to
>   the current Linux coding style convention.
>
> * Let us delete also an unnecessary check for the variable "entry" there.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/netlabel/netlabel_mgmt.c | 49 ++++++++++++++++++++++----------------------
>  1 file changed, 24 insertions(+), 25 deletions(-)

Thanks for fixing the label names.

Acked-by: Paul Moore <paul@paul-moore.com>

> diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
> index f5807f5..7044074 100644
> --- a/net/netlabel/netlabel_mgmt.c
> +++ b/net/netlabel/netlabel_mgmt.c
> @@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                                   struct netlbl_audit *audit_info)
>  {
>         int ret_val = -EINVAL;
> -       struct netlbl_dom_map *entry = NULL;
>         struct netlbl_domaddr_map *addrmap = NULL;
>         struct cipso_v4_doi *cipsov4 = NULL;
>         u32 tmp_val;
> +       struct netlbl_dom_map *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
>
> -       entry = kzalloc(sizeof(*entry), GFP_KERNEL);
> -       if (entry == NULL) {
> -               ret_val = -ENOMEM;
> -               goto add_failure;
> -       }
> +       if (!entry)
> +               return -ENOMEM;
>         entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
>         if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
>                 size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
>                 entry->domain = kmalloc(tmp_size, GFP_KERNEL);
>                 if (entry->domain == NULL) {
>                         ret_val = -ENOMEM;
> -                       goto add_failure;
> +                       goto add_free_entry;
>                 }
>                 nla_strlcpy(entry->domain,
>                             info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
> @@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 break;
>         case NETLBL_NLTYPE_CIPSOV4:
>                 if (!info->attrs[NLBL_MGMT_A_CV4DOI])
> -                       goto add_failure;
> +                       goto add_free_domain;
>
>                 tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
>                 cipsov4 = cipso_v4_doi_getdef(tmp_val);
>                 if (cipsov4 == NULL)
> -                       goto add_failure;
> +                       goto add_free_domain;
>                 entry->def.cipso = cipsov4;
>                 break;
>         default:
> -               goto add_failure;
> +               goto add_free_domain;
>         }
>
>         if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) {
> @@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
>                 if (addrmap == NULL) {
>                         ret_val = -ENOMEM;
> -                       goto add_failure;
> +                       goto add_doi_put_def;
>                 }
>                 INIT_LIST_HEAD(&addrmap->list4);
>                 INIT_LIST_HEAD(&addrmap->list6);
> @@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !=
>                     sizeof(struct in_addr)) {
>                         ret_val = -EINVAL;
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>                 if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !=
>                     sizeof(struct in_addr)) {
>                         ret_val = -EINVAL;
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>                 addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
>                 mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
> @@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 map = kzalloc(sizeof(*map), GFP_KERNEL);
>                 if (map == NULL) {
>                         ret_val = -ENOMEM;
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>                 map->list.addr = addr->s_addr & mask->s_addr;
>                 map->list.mask = mask->s_addr;
> @@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
>                 if (ret_val != 0) {
>                         kfree(map);
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>
>                 entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
> @@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
>                 if (addrmap == NULL) {
>                         ret_val = -ENOMEM;
> -                       goto add_failure;
> +                       goto add_doi_put_def;
>                 }
>                 INIT_LIST_HEAD(&addrmap->list4);
>                 INIT_LIST_HEAD(&addrmap->list6);
> @@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !=
>                     sizeof(struct in6_addr)) {
>                         ret_val = -EINVAL;
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>                 if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !=
>                     sizeof(struct in6_addr)) {
>                         ret_val = -EINVAL;
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>                 addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
>                 mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
> @@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 map = kzalloc(sizeof(*map), GFP_KERNEL);
>                 if (map == NULL) {
>                         ret_val = -ENOMEM;
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>                 map->list.addr = *addr;
>                 map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
> @@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>                 ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
>                 if (ret_val != 0) {
>                         kfree(map);
> -                       goto add_failure;
> +                       goto add_free_addrmap;
>                 }
>
>                 entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
> @@ -237,15 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
>
>         ret_val = netlbl_domhsh_add(entry, audit_info);
>         if (ret_val != 0)
> -               goto add_failure;
> +               goto add_free_addrmap;
>
>         return 0;
>
> -add_failure:
> -       cipso_v4_doi_putdef(cipsov4);
> -       if (entry)
> -               kfree(entry->domain);
> +add_free_addrmap:
>         kfree(addrmap);
> +add_doi_put_def:
> +       cipso_v4_doi_putdef(cipsov4);
> +add_free_domain:
> +       kfree(entry->domain);
> +add_free_entry:
>         kfree(entry);
>         return ret_val;
>  }
> --
> 2.2.2
>



-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH v2 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
  2015-02-01 10:15                                         ` [PATCH v2 " SF Markus Elfring
  2015-02-01 14:39                                           ` Paul Moore
@ 2015-02-01 20:30                                           ` David Miller
  2015-02-02 10:22                                             ` [PATCH v3 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: David Miller @ 2015-02-01 20:30 UTC (permalink / raw)
  To: elfring; +Cc: paul, netdev, linux-kernel, kernel-janitors, julia.lawall


When you post a new version of a patch within a series, you must repost
the entire series, not just the patch which is changing.

Thanks.

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

* [PATCH v3 0/3] netlabel: Deletion of a few unnecessary checks
  2015-02-01 20:30                                           ` David Miller
@ 2015-02-02 10:22                                             ` SF Markus Elfring
  2015-02-02 10:25                                               ` [PATCH v3 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
                                                                 ` (2 more replies)
  0 siblings, 3 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-02 10:22 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Feb 2015 11:15:56 +0100

Further update suggestions were taken into account after patches were applied
from static source code analysis.

Markus Elfring (3):
  Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
  Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
  Less function calls in netlbl_mgmt_add_common() after error detection

 net/netlabel/netlabel_cipso_v4.c |  3 +--
 net/netlabel/netlabel_mgmt.c     | 50 +++++++++++++++++++---------------------
 2 files changed, 25 insertions(+), 28 deletions(-)

-- 
2.2.2

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

* [PATCH v3 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef"
  2015-02-02 10:22                                             ` [PATCH v3 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-02-02 10:25                                               ` SF Markus Elfring
  2015-02-02 10:26                                               ` [PATCH v3 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
  2015-02-02 11:06                                               ` [PATCH v3 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
  2 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-02 10:25 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Feb 2015 10:01:45 +0100

The cipso_v4_doi_putdef() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Paul Moore <paul@paul-moore.com>
---
 net/netlabel/netlabel_mgmt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index 8b3b789..f5807f5 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -242,8 +242,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 	return 0;
 
 add_failure:
-	if (cipsov4)
-		cipso_v4_doi_putdef(cipsov4);
+	cipso_v4_doi_putdef(cipsov4);
 	if (entry)
 		kfree(entry->domain);
 	kfree(addrmap);
-- 
2.2.2


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

* [PATCH v3 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free"
  2015-02-02 10:22                                             ` [PATCH v3 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
  2015-02-02 10:25                                               ` [PATCH v3 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
@ 2015-02-02 10:26                                               ` SF Markus Elfring
  2015-02-02 11:06                                               ` [PATCH v3 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
  2 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-02 10:26 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Feb 2015 10:40:30 +0100

The cipso_v4_doi_free() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Paul Moore <paul@paul-moore.com>
---
 net/netlabel/netlabel_cipso_v4.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
index 1796253..7fd1104 100644
--- a/net/netlabel/netlabel_cipso_v4.c
+++ b/net/netlabel/netlabel_cipso_v4.c
@@ -324,8 +324,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
 	return 0;
 
 add_std_failure:
-	if (doi_def)
-		cipso_v4_doi_free(doi_def);
+	cipso_v4_doi_free(doi_def);
 	return ret_val;
 }
 
-- 
2.2.2


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

* [PATCH v3 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection
  2015-02-02 10:22                                             ` [PATCH v3 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
  2015-02-02 10:25                                               ` [PATCH v3 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
  2015-02-02 10:26                                               ` [PATCH v3 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
@ 2015-02-02 11:06                                               ` SF Markus Elfring
  2 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-02 11:06 UTC (permalink / raw)
  To: David S. Miller, Paul Moore, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 2 Feb 2015 11:00:24 +0100

The functions "cipso_v4_doi_putdef" and "kfree" could be called in some cases
by the netlbl_mgmt_add_common() function during error handling even if the
passed variables contained still a null pointer.

* This implementation detail could be improved by adjustments for jump labels.

* Let us return immediately after the first failed function call according to
  the current Linux coding style convention.

* Let us delete also an unnecessary check for the variable "entry" there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Paul Moore <paul@paul-moore.com>
---
 net/netlabel/netlabel_mgmt.c | 49 ++++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
index f5807f5..7044074 100644
--- a/net/netlabel/netlabel_mgmt.c
+++ b/net/netlabel/netlabel_mgmt.c
@@ -93,23 +93,20 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 				  struct netlbl_audit *audit_info)
 {
 	int ret_val = -EINVAL;
-	struct netlbl_dom_map *entry = NULL;
 	struct netlbl_domaddr_map *addrmap = NULL;
 	struct cipso_v4_doi *cipsov4 = NULL;
 	u32 tmp_val;
+	struct netlbl_dom_map *entry = kzalloc(sizeof(*entry), GFP_KERNEL);
 
-	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
-	if (entry == NULL) {
-		ret_val = -ENOMEM;
-		goto add_failure;
-	}
+	if (!entry)
+		return -ENOMEM;
 	entry->def.type = nla_get_u32(info->attrs[NLBL_MGMT_A_PROTOCOL]);
 	if (info->attrs[NLBL_MGMT_A_DOMAIN]) {
 		size_t tmp_size = nla_len(info->attrs[NLBL_MGMT_A_DOMAIN]);
 		entry->domain = kmalloc(tmp_size, GFP_KERNEL);
 		if (entry->domain == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_free_entry;
 		}
 		nla_strlcpy(entry->domain,
 			    info->attrs[NLBL_MGMT_A_DOMAIN], tmp_size);
@@ -125,16 +122,16 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		break;
 	case NETLBL_NLTYPE_CIPSOV4:
 		if (!info->attrs[NLBL_MGMT_A_CV4DOI])
-			goto add_failure;
+			goto add_free_domain;
 
 		tmp_val = nla_get_u32(info->attrs[NLBL_MGMT_A_CV4DOI]);
 		cipsov4 = cipso_v4_doi_getdef(tmp_val);
 		if (cipsov4 == NULL)
-			goto add_failure;
+			goto add_free_domain;
 		entry->def.cipso = cipsov4;
 		break;
 	default:
-		goto add_failure;
+		goto add_free_domain;
 	}
 
 	if (info->attrs[NLBL_MGMT_A_IPV4ADDR]) {
@@ -145,7 +142,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
 		if (addrmap == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_doi_put_def;
 		}
 		INIT_LIST_HEAD(&addrmap->list4);
 		INIT_LIST_HEAD(&addrmap->list6);
@@ -153,12 +150,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV4ADDR]) !=
 		    sizeof(struct in_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV4MASK]) !=
 		    sizeof(struct in_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		addr = nla_data(info->attrs[NLBL_MGMT_A_IPV4ADDR]);
 		mask = nla_data(info->attrs[NLBL_MGMT_A_IPV4MASK]);
@@ -166,7 +163,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (map == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		map->list.addr = addr->s_addr & mask->s_addr;
 		map->list.mask = mask->s_addr;
@@ -178,7 +175,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
 		if (ret_val != 0) {
 			kfree(map);
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 
 		entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
@@ -192,7 +189,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		addrmap = kzalloc(sizeof(*addrmap), GFP_KERNEL);
 		if (addrmap == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_doi_put_def;
 		}
 		INIT_LIST_HEAD(&addrmap->list4);
 		INIT_LIST_HEAD(&addrmap->list6);
@@ -200,12 +197,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV6ADDR]) !=
 		    sizeof(struct in6_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		if (nla_len(info->attrs[NLBL_MGMT_A_IPV6MASK]) !=
 		    sizeof(struct in6_addr)) {
 			ret_val = -EINVAL;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		addr = nla_data(info->attrs[NLBL_MGMT_A_IPV6ADDR]);
 		mask = nla_data(info->attrs[NLBL_MGMT_A_IPV6MASK]);
@@ -213,7 +210,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		map = kzalloc(sizeof(*map), GFP_KERNEL);
 		if (map == NULL) {
 			ret_val = -ENOMEM;
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 		map->list.addr = *addr;
 		map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
@@ -227,7 +224,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 		ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
 		if (ret_val != 0) {
 			kfree(map);
-			goto add_failure;
+			goto add_free_addrmap;
 		}
 
 		entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
@@ -237,15 +234,17 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
 
 	ret_val = netlbl_domhsh_add(entry, audit_info);
 	if (ret_val != 0)
-		goto add_failure;
+		goto add_free_addrmap;
 
 	return 0;
 
-add_failure:
-	cipso_v4_doi_putdef(cipsov4);
-	if (entry)
-		kfree(entry->domain);
+add_free_addrmap:
 	kfree(addrmap);
+add_doi_put_def:
+	cipso_v4_doi_putdef(cipsov4);
+add_free_domain:
+	kfree(entry->domain);
+add_free_entry:
 	kfree(entry);
 	return ret_val;
 }
-- 
2.2.2

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

* Re: [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree"
  2015-01-31 17:15                                   ` [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
  2015-01-31 18:38                                     ` Neil Horman
@ 2015-02-03  3:30                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-03  3:30 UTC (permalink / raw)
  To: elfring
  Cc: nhorman, vyasevich, linux-sctp, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 18:15:59 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 18:10:03 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to net-next, thanks.

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

* [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (17 preceding siblings ...)
  2015-01-31 21:14                                   ` [PATCH 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-02-03 18:51                                   ` SF Markus Elfring
  2015-02-05  4:29                                     ` David Miller
  2015-02-03 19:22                                   ` [PATCH] NetCP: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                     ` (35 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-03 18:51 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 19:47:33 +0100

The of_dev_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/ibm/emac/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index 9388a83..162762d 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2367,7 +2367,7 @@ static int emac_wait_deps(struct emac_instance *dev)
 	err = emac_check_deps(dev, deps) ? 0 : -ENODEV;
 	for (i = 0; i < EMAC_DEP_COUNT; i++) {
 		of_node_put(deps[i].node);
-		if (err && deps[i].ofdev)
+		if (err)
 			of_dev_put(deps[i].ofdev);
 	}
 	if (err == 0) {
-- 
2.2.2

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

* [PATCH] NetCP: Deletion of unnecessary checks before two function calls
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (18 preceding siblings ...)
  2015-02-03 18:51                                   ` [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put" SF Markus Elfring
@ 2015-02-03 19:22                                   ` SF Markus Elfring
  2015-02-05  4:30                                     ` David Miller
  2015-02-05 12:01                                     ` Dan Carpenter
  2015-02-04 10:38                                   ` [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
                                                     ` (34 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-03 19:22 UTC (permalink / raw)
  To: Murali Karicheri, Wingman Kwok, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Feb 2015 20:12:25 +0100

The functions cpsw_ale_destroy() and of_dev_put() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index fa1041a..cbd6dde 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -2010,12 +2010,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
 quit:
 	if (gbe_dev->hw_stats)
 		devm_kfree(dev, gbe_dev->hw_stats);
-	if (gbe_dev->ale)
-		cpsw_ale_destroy(gbe_dev->ale);
+	cpsw_ale_destroy(gbe_dev->ale);
 	if (gbe_dev->ss_regs)
 		devm_iounmap(dev, gbe_dev->ss_regs);
-	if (interfaces)
-		of_node_put(interfaces);
+	of_node_put(interfaces);
 	devm_kfree(dev, gbe_dev);
 	return ret;
 }
-- 
2.2.2

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-01-31 16:34                                   ` [PATCH] net: sched: One function call less in em_meta_change() after error detection SF Markus Elfring
  2015-01-31 17:31                                     ` Lino Sanfilippo
  2015-01-31 17:50                                     ` Lino Sanfilippo
@ 2015-02-04  0:10                                     ` David Miller
  2015-02-04  9:54                                       ` SF Markus Elfring
  2 siblings, 1 reply; 273+ messages in thread
From: David Miller @ 2015-02-04  0:10 UTC (permalink / raw)
  To: elfring; +Cc: jhs, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 31 Jan 2015 17:34:54 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 31 Jan 2015 17:18:48 +0100
> 
> The meta_delete() function could be called in four cases by the
> em_meta_change() function during error handling even if the passed
> variable "meta" contained still a null pointer.
> 
> * This implementation detail could be improved by adjustments for jump labels.
> 
> * Let us return immediately after the first failed function call according to
>   the current Linux coding style convention.
> 
> * Let us delete also unnecessary checks for the variables "err" and
>   "meta" there.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

I kind of like the way the code is now, branching to the end of the function
even when cleanups are not necessary.

Inter-function return statements make code harder to audit, for locking
errors, resource leaks, etc.

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

* Re: [PATCH] net: sched: One function call less in em_meta_change() after error detection
  2015-02-04  0:10                                     ` David Miller
@ 2015-02-04  9:54                                       ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04  9:54 UTC (permalink / raw)
  To: David Miller
  Cc: Jamal Hadi Salim, netdev, linux-kernel, kernel-janitors, Julia Lawall

>> The meta_delete() function could be called in four cases by the
>> em_meta_change() function during error handling even if the passed
>> variable "meta" contained still a null pointer.
>>
>> * This implementation detail could be improved by adjustments for jump labels.
>>
>> * Let us return immediately after the first failed function call according to
>>   the current Linux coding style convention.
>>
>> * Let us delete also unnecessary checks for the variables "err" and
>>   "meta" there.
> 
> I kind of like the way the code is now, branching to the end of the function
> even when cleanups are not necessary.

I would appreciate if the affected exception handling can become also
a bit more efficient.

Regards,
Markus


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

* [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (19 preceding siblings ...)
  2015-02-03 19:22                                   ` [PATCH] NetCP: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2015-02-04 10:38                                   ` SF Markus Elfring
  2015-02-05  8:07                                     ` David Miller
  2015-02-04 11:36                                   ` [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
                                                     ` (33 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 10:38 UTC (permalink / raw)
  To: Hariprasad S, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 11:28:43 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 1147e1e..6d08b8c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -5129,8 +5129,7 @@ static int adap_init0(struct adapter *adap)
 				 state, &reset);
 
 		/* Cleaning up */
-		if (fw != NULL)
-			release_firmware(fw);
+		release_firmware(fw);
 		t4_free_mem(card_fw);
 
 		if (ret < 0)
-- 
2.2.2

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

* [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (20 preceding siblings ...)
  2015-02-04 10:38                                   ` [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2015-02-04 11:36                                   ` SF Markus Elfring
  2015-02-05  8:25                                     ` David Miller
  2015-02-04 12:00                                   ` [PATCH] net: fec: Delete unnecessary checks " SF Markus Elfring
                                                     ` (32 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 11:36 UTC (permalink / raw)
  To: Hyong-Youb Kim, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 12:32:14 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/myricom/myri10ge/myri10ge.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index 71af98b..1412f5a 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -4226,8 +4226,7 @@ static void myri10ge_remove(struct pci_dev *pdev)
 		mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
 #endif
 	myri10ge_free_slices(mgp);
-	if (mgp->msix_vectors != NULL)
-		kfree(mgp->msix_vectors);
+	kfree(mgp->msix_vectors);
 	dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
 			  mgp->cmd, mgp->cmd_bus);
 
-- 
2.2.2

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

* [PATCH] net: fec: Delete unnecessary checks before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (21 preceding siblings ...)
  2015-02-04 11:36                                   ` [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-02-04 12:00                                   ` SF Markus Elfring
  2015-02-05  8:26                                     ` David Miller
  2015-02-04 12:21                                   ` [PATCH] netxen: Delete an unnecessary check " SF Markus Elfring
                                                     ` (31 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 12:00 UTC (permalink / raw)
  To: netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 12:56:42 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/fec_main.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 1c7a7e4..29fd7e3 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2584,12 +2584,9 @@ static void fec_enet_free_queue(struct net_device *ndev)
 		}
 
 	for (i = 0; i < fep->num_rx_queues; i++)
-		if (fep->rx_queue[i])
-			kfree(fep->rx_queue[i]);
-
+		kfree(fep->rx_queue[i]);
 	for (i = 0; i < fep->num_tx_queues; i++)
-		if (fep->tx_queue[i])
-			kfree(fep->tx_queue[i]);
+		kfree(fep->tx_queue[i]);
 }
 
 static int fec_enet_alloc_queue(struct net_device *ndev)
-- 
2.2.2

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

* [PATCH] netxen: Delete an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (22 preceding siblings ...)
  2015-02-04 12:00                                   ` [PATCH] net: fec: Delete unnecessary checks " SF Markus Elfring
@ 2015-02-04 12:21                                   ` SF Markus Elfring
  2015-02-05  8:26                                     ` David Miller
  2015-02-04 13:13                                   ` [PATCH] qlogic: Deletion of unnecessary checks before two function calls SF Markus Elfring
                                                     ` (30 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 12:21 UTC (permalink / raw)
  To: Manish Chopra, Rajesh Borundia, Sony Chacko, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 13:17:48 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index a47fe67..7d1b524 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -176,9 +176,7 @@ netxen_alloc_sds_rings(struct netxen_recv_context *recv_ctx, int count)
 static void
 netxen_free_sds_rings(struct netxen_recv_context *recv_ctx)
 {
-	if (recv_ctx->sds_rings != NULL)
-		kfree(recv_ctx->sds_rings);
-
+	kfree(recv_ctx->sds_rings);
 	recv_ctx->sds_rings = NULL;
 }
 
-- 
2.2.2

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

* [PATCH] qlogic: Deletion of unnecessary checks before two function calls
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (23 preceding siblings ...)
  2015-02-04 12:21                                   ` [PATCH] netxen: Delete an unnecessary check " SF Markus Elfring
@ 2015-02-04 13:13                                   ` SF Markus Elfring
  2015-02-05  8:33                                     ` David Miller
  2015-02-04 15:00                                   ` [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree" SF Markus Elfring
                                                     ` (29 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 13:13 UTC (permalink / raw)
  To: Shahed Shaikh, Dept-GELinuxNICDev, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 14:07:56 +0100

The functions kfree() and vfree() perform also input parameter validation.
Thus the test around their calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c   | 24 ++++++++--------------
 .../net/ethernet/qlogic/qlcnic/qlcnic_minidump.c   |  3 +--
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 2528c3f..a430a34a 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -294,9 +294,7 @@ int qlcnic_alloc_sds_rings(struct qlcnic_recv_context *recv_ctx, int count)
 
 void qlcnic_free_sds_rings(struct qlcnic_recv_context *recv_ctx)
 {
-	if (recv_ctx->sds_rings != NULL)
-		kfree(recv_ctx->sds_rings);
-
+	kfree(recv_ctx->sds_rings);
 	recv_ctx->sds_rings = NULL;
 }
 
@@ -1257,8 +1255,7 @@ qlcnic_check_options(struct qlcnic_adapter *adapter)
 	if (ahw->op_mode != QLCNIC_NON_PRIV_FUNC) {
 		if (fw_dump->tmpl_hdr == NULL ||
 				adapter->fw_version > prev_fw_version) {
-			if (fw_dump->tmpl_hdr)
-				vfree(fw_dump->tmpl_hdr);
+			vfree(fw_dump->tmpl_hdr);
 			if (!qlcnic_fw_cmd_get_minidump_temp(adapter))
 				dev_info(&pdev->dev,
 					"Supports FW dump capability\n");
@@ -2374,13 +2371,12 @@ void qlcnic_free_tx_rings(struct qlcnic_adapter *adapter)
 
 	for (ring = 0; ring < adapter->drv_tx_rings; ring++) {
 		tx_ring = &adapter->tx_ring[ring];
-		if (tx_ring && tx_ring->cmd_buf_arr != NULL) {
+		if (tx_ring) {
 			vfree(tx_ring->cmd_buf_arr);
 			tx_ring->cmd_buf_arr = NULL;
 		}
 	}
-	if (adapter->tx_ring != NULL)
-		kfree(adapter->tx_ring);
+	kfree(adapter->tx_ring);
 }
 
 int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter,
@@ -2758,13 +2754,9 @@ static void qlcnic_remove(struct pci_dev *pdev)
 	}
 
 	qlcnic_dcb_free(adapter->dcb);
-
 	qlcnic_detach(adapter);
-
-	if (adapter->npars != NULL)
-		kfree(adapter->npars);
-	if (adapter->eswitch != NULL)
-		kfree(adapter->eswitch);
+	kfree(adapter->npars);
+	kfree(adapter->eswitch);
 
 	if (qlcnic_82xx_check(adapter))
 		qlcnic_clr_all_drv_state(adapter, 0);
@@ -2932,13 +2924,13 @@ void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter)
 
 static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter)
 {
-	if (adapter->fhash.fmax && adapter->fhash.fhead)
+	if (adapter->fhash.fmax)
 		kfree(adapter->fhash.fhead);
 
 	adapter->fhash.fhead = NULL;
 	adapter->fhash.fmax = 0;
 
-	if (adapter->rx_fhash.fmax && adapter->rx_fhash.fhead)
+	if (adapter->rx_fhash.fmax)
 		kfree(adapter->rx_fhash.fhead);
 
 	adapter->rx_fhash.fmax = 0;
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
index c9f57fb..332bb8a 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
@@ -1407,8 +1407,7 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter)
 	current_version = qlcnic_83xx_get_fw_version(adapter);
 
 	if (fw_dump->tmpl_hdr == NULL || current_version > prev_version) {
-		if (fw_dump->tmpl_hdr)
-			vfree(fw_dump->tmpl_hdr);
+		vfree(fw_dump->tmpl_hdr);
 		if (!qlcnic_fw_cmd_get_minidump_temp(adapter))
 			dev_info(&pdev->dev, "Supports FW dump capability\n");
 	}
-- 
2.2.2

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

* [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
       [not found]                                 ` <5317A59D.4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-02-04 14:22                                   ` SF Markus Elfring
  2015-02-04 14:59                                     ` Eli Cohen
       [not found]                                     ` <54D22B29.3020200-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-11-15  8:40                                   ` [PATCH 0/2] batman-adv: Deletion of some unnecessary checks SF Markus Elfring
  1 sibling, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 14:22 UTC (permalink / raw)
  To: Eli Cohen, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Wed, 4 Feb 2015 15:17:00 +0100

The vunmap() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 drivers/net/ethernet/mellanox/mlx4/alloc.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c
index 963dd7e..06faa51 100644
--- a/drivers/net/ethernet/mellanox/mlx4/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c
@@ -660,7 +660,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)
 		dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf,
 				  buf->direct.map);
 	else {
-		if (BITS_PER_LONG == 64 && buf->direct.buf)
+		if (BITS_PER_LONG == 64)
 			vunmap(buf->direct.buf);
 
 		for (i = 0; i < buf->nbufs; ++i)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
index 56779c1..201ca6d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
@@ -121,7 +121,7 @@ void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf)
 		dma_free_coherent(&dev->pdev->dev, buf->size, buf->direct.buf,
 				  buf->direct.map);
 	else {
-		if (BITS_PER_LONG == 64 && buf->direct.buf)
+		if (BITS_PER_LONG == 64)
 			vunmap(buf->direct.buf);
 
 		for (i = 0; i < buf->nbufs; i++)
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
  2015-02-04 14:22                                   ` [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap" SF Markus Elfring
@ 2015-02-04 14:59                                     ` Eli Cohen
       [not found]                                     ` <54D22B29.3020200-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  1 sibling, 0 replies; 273+ messages in thread
From: Eli Cohen @ 2015-02-04 14:59 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: netdev, linux-rdma, LKML, kernel-janitors, Julia Lawall

Acked-by: Eli Cohen <eli@mellanox.com>

On Wed, Feb 04, 2015 at 03:22:33PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 15:17:00 +0100
> 
> The vunmap() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

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

* [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (24 preceding siblings ...)
  2015-02-04 13:13                                   ` [PATCH] qlogic: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2015-02-04 15:00                                   ` SF Markus Elfring
  2015-02-04 15:59                                     ` Hartley Sweeten
  2015-02-05  8:37                                     ` David Miller
  2015-02-04 16:45                                   ` [PATCH 0/2] CW1200: Deletion of an unnecessary check SF Markus Elfring
                                                     ` (28 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 15:00 UTC (permalink / raw)
  To: Hartley Sweeten, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 15:56:58 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/cirrus/ep93xx_eth.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
index 3a12c09..de9f7c9 100644
--- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
+++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
@@ -475,8 +475,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)
 		if (d)
 			dma_unmap_single(dev, d, PKT_BUF_SIZE, DMA_FROM_DEVICE);
 
-		if (ep->rx_buf[i] != NULL)
-			kfree(ep->rx_buf[i]);
+		kfree(ep->rx_buf[i]);
 	}
 
 	for (i = 0; i < TX_QUEUE_ENTRIES; i++) {
@@ -486,8 +485,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)
 		if (d)
 			dma_unmap_single(dev, d, PKT_BUF_SIZE, DMA_TO_DEVICE);
 
-		if (ep->tx_buf[i] != NULL)
-			kfree(ep->tx_buf[i]);
+		kfree(ep->tx_buf[i]);
 	}
 
 	dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs,
-- 
2.2.2


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

* RE: [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
  2015-02-04 15:00                                   ` [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2015-02-04 15:59                                     ` Hartley Sweeten
  2015-02-05  8:37                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: Hartley Sweeten @ 2015-02-04 15:59 UTC (permalink / raw)
  To: SF Markus Elfring, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

On Wednesday, February 04, 2015 8:01 AM, Markus Elfring wrote:
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ethernet/cirrus/ep93xx_eth.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/cirrus/ep93xx_eth.c b/drivers/net/ethernet/cirrus/ep93xx_eth.c
> index 3a12c09..de9f7c9 100644
> --- a/drivers/net/ethernet/cirrus/ep93xx_eth.c
> +++ b/drivers/net/ethernet/cirrus/ep93xx_eth.c
> @@ -475,8 +475,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)
>  		if (d)
>  			dma_unmap_single(dev, d, PKT_BUF_SIZE, DMA_FROM_DEVICE);
>  
> -		if (ep->rx_buf[i] != NULL)
> -			kfree(ep->rx_buf[i]);
> +		kfree(ep->rx_buf[i]);
>  	}
>  
>  	for (i = 0; i < TX_QUEUE_ENTRIES; i++) {
> @@ -486,8 +485,7 @@ static void ep93xx_free_buffers(struct ep93xx_priv *ep)
>  		if (d)
>  			dma_unmap_single(dev, d, PKT_BUF_SIZE, DMA_TO_DEVICE);
>  
> -		if (ep->tx_buf[i] != NULL)
> -			kfree(ep->tx_buf[i]);
> +		kfree(ep->tx_buf[i]);
>  	}
>  
>  	dma_free_coherent(dev, sizeof(struct ep93xx_descs), ep->descs,

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>

Thanks

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

* [PATCH 0/2] CW1200: Deletion of an unnecessary check
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (25 preceding siblings ...)
  2015-02-04 15:00                                   ` [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree" SF Markus Elfring
@ 2015-02-04 16:45                                   ` SF Markus Elfring
  2015-02-04 16:47                                     ` [PATCH 1/2] CW1200: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
  2015-02-04 16:48                                     ` [PATCH 2/2] CW1200: Less function calls in cw1200_load_firmware_cw1200() after error detection SF Markus Elfring
  2015-02-04 17:54                                   ` [PATCH] ath9k: Delete an unnecessary check before the function call "relay_close" SF Markus Elfring
                                                     ` (27 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 16:45 UTC (permalink / raw)
  To: Kalle Valo, Solomon Peachy, netdev, linux-wireless
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 17:31:00 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary check before the function call "release_firmware"
  Less function calls in cw1200_load_firmware_cw1200() after error detection

 drivers/net/wireless/cw1200/fwio.c | 40 +++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 16 deletions(-)

-- 
2.2.2

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

* [PATCH 1/2] CW1200: Delete an unnecessary check before the function call "release_firmware"
  2015-02-04 16:45                                   ` [PATCH 0/2] CW1200: Deletion of an unnecessary check SF Markus Elfring
@ 2015-02-04 16:47                                     ` SF Markus Elfring
  2015-02-06  6:49                                       ` [1/2] cw1200: " Kalle Valo
  2015-02-04 16:48                                     ` [PATCH 2/2] CW1200: Less function calls in cw1200_load_firmware_cw1200() after error detection SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 16:47 UTC (permalink / raw)
  To: Kalle Valo, Solomon Peachy, netdev, linux-wireless
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 16:32:15 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/cw1200/fwio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/cw1200/fwio.c b/drivers/net/wireless/cw1200/fwio.c
index 6f1b9aa..581dfde 100644
--- a/drivers/net/wireless/cw1200/fwio.c
+++ b/drivers/net/wireless/cw1200/fwio.c
@@ -246,8 +246,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 
 error:
 	kfree(buf);
-	if (firmware)
-		release_firmware(firmware);
+	release_firmware(firmware);
 	return ret;
 
 #undef APB_WRITE
-- 
2.2.2

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

* [PATCH 2/2] CW1200: Less function calls in cw1200_load_firmware_cw1200() after error detection
  2015-02-04 16:45                                   ` [PATCH 0/2] CW1200: Deletion of an unnecessary check SF Markus Elfring
  2015-02-04 16:47                                     ` [PATCH 1/2] CW1200: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2015-02-04 16:48                                     ` SF Markus Elfring
  1 sibling, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 16:48 UTC (permalink / raw)
  To: Kalle Valo, Solomon Peachy, netdev, linux-wireless
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 17:28:41 +0100

The functions kfree() and release_firmware() were called in a few cases
by the cw1200_load_firmware_cw1200() function during error handling even if
the passed variables contained still a null pointer.

Corresponding implementation details could be improved by adjustments for
jump targets.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/cw1200/fwio.c | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/cw1200/fwio.c b/drivers/net/wireless/cw1200/fwio.c
index 581dfde..30e7646 100644
--- a/drivers/net/wireless/cw1200/fwio.c
+++ b/drivers/net/wireless/cw1200/fwio.c
@@ -66,25 +66,31 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 	do { \
 		ret = cw1200_apb_write_32(priv, CW1200_APB(reg), (val)); \
 		if (ret < 0) \
-			goto error; \
+			goto exit; \
+	} while (0)
+#define APB_WRITE2(reg, val) \
+	do { \
+		ret = cw1200_apb_write_32(priv, CW1200_APB(reg), (val)); \
+		if (ret < 0) \
+			goto free_buffer; \
 	} while (0)
 #define APB_READ(reg, val) \
 	do { \
 		ret = cw1200_apb_read_32(priv, CW1200_APB(reg), &(val)); \
 		if (ret < 0) \
-			goto error; \
+			goto free_buffer; \
 	} while (0)
 #define REG_WRITE(reg, val) \
 	do { \
 		ret = cw1200_reg_write_32(priv, (reg), (val)); \
 		if (ret < 0) \
-			goto error; \
+			goto exit; \
 	} while (0)
 #define REG_READ(reg, val) \
 	do { \
 		ret = cw1200_reg_read_32(priv, (reg), &(val)); \
 		if (ret < 0) \
-			goto error; \
+			goto exit; \
 	} while (0)
 
 	switch (priv->hw_revision) {
@@ -142,14 +148,14 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 	ret = request_firmware(&firmware, fw_path, priv->pdev);
 	if (ret) {
 		pr_err("Can't load firmware file %s.\n", fw_path);
-		goto error;
+		goto exit;
 	}
 
 	buf = kmalloc(DOWNLOAD_BLOCK_SIZE, GFP_KERNEL | GFP_DMA);
 	if (!buf) {
 		pr_err("Can't allocate firmware load buffer.\n");
 		ret = -ENOMEM;
-		goto error;
+		goto firmware_release;
 	}
 
 	/* Check if the bootloader is ready */
@@ -163,7 +169,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 	if (val32 != DOWNLOAD_I_AM_HERE) {
 		pr_err("Bootloader is not ready.\n");
 		ret = -ETIMEDOUT;
-		goto error;
+		goto free_buffer;
 	}
 
 	/* Calculcate number of download blocks */
@@ -171,7 +177,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 
 	/* Updating the length in Download Ctrl Area */
 	val32 = firmware->size; /* Explicit cast from size_t to u32 */
-	APB_WRITE(DOWNLOAD_IMAGE_SIZE_REG, val32);
+	APB_WRITE2(DOWNLOAD_IMAGE_SIZE_REG, val32);
 
 	/* Firmware downloading loop */
 	for (block = 0; block < num_blocks; block++) {
@@ -183,7 +189,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 		if (val32 != DOWNLOAD_PENDING) {
 			pr_err("Bootloader reported error %d.\n", val32);
 			ret = -EIO;
-			goto error;
+			goto free_buffer;
 		}
 
 		/* loop until put - get <= 24K */
@@ -198,7 +204,7 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 		if ((put - get) > (DOWNLOAD_FIFO_SIZE - DOWNLOAD_BLOCK_SIZE)) {
 			pr_err("Timeout waiting for FIFO.\n");
 			ret = -ETIMEDOUT;
-			goto error;
+			goto free_buffer;
 		}
 
 		/* calculate the block size */
@@ -220,12 +226,12 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 		if (ret < 0) {
 			pr_err("Can't write firmware block @ %d!\n",
 			       put & (DOWNLOAD_FIFO_SIZE - 1));
-			goto error;
+			goto free_buffer;
 		}
 
 		/* update the put register */
 		put += block_size;
-		APB_WRITE(DOWNLOAD_PUT_REG, put);
+		APB_WRITE2(DOWNLOAD_PUT_REG, put);
 	} /* End of firmware download loop */
 
 	/* Wait for the download completion */
@@ -238,18 +244,21 @@ static int cw1200_load_firmware_cw1200(struct cw1200_common *priv)
 	if (val32 != DOWNLOAD_SUCCESS) {
 		pr_err("Wait for download completion failed: 0x%.8X\n", val32);
 		ret = -ETIMEDOUT;
-		goto error;
+		goto free_buffer;
 	} else {
 		pr_info("Firmware download completed.\n");
 		ret = 0;
 	}
 
-error:
+free_buffer:
 	kfree(buf);
+firmware_release:
 	release_firmware(firmware);
+exit:
 	return ret;
 
 #undef APB_WRITE
+#undef APB_WRITE2
 #undef APB_READ
 #undef REG_WRITE
 #undef REG_READ
-- 
2.2.2

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

* [PATCH] ath9k: Delete an unnecessary check before the function call "relay_close"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (26 preceding siblings ...)
  2015-02-04 16:45                                   ` [PATCH 0/2] CW1200: Deletion of an unnecessary check SF Markus Elfring
@ 2015-02-04 17:54                                   ` SF Markus Elfring
  2015-02-06  6:50                                     ` ath9k: Delete an unnecessary check before the function call"relay_close" Kalle Valo
  2015-02-04 18:33                                   ` [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware" SF Markus Elfring
                                                     ` (26 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 17:54 UTC (permalink / raw)
  To: Kalle Valo, ath9k-devel, linux-wireless, QCA ath9k Development, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 18:48:28 +0100

The relay_close() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/ath/ath9k/common-spectral.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/common-spectral.c b/drivers/net/wireless/ath/ath9k/common-spectral.c
index ec93ddf..5cee231 100644
--- a/drivers/net/wireless/ath/ath9k/common-spectral.c
+++ b/drivers/net/wireless/ath/ath9k/common-spectral.c
@@ -582,7 +582,7 @@ static struct rchan_callbacks rfs_spec_scan_cb = {
 
 void ath9k_cmn_spectral_deinit_debug(struct ath_spec_scan_priv *spec_priv)
 {
-	if (config_enabled(CONFIG_ATH9K_DEBUGFS) && spec_priv->rfs_chan_spec_scan) {
+	if (config_enabled(CONFIG_ATH9K_DEBUGFS)) {
 		relay_close(spec_priv->rfs_chan_spec_scan);
 		spec_priv->rfs_chan_spec_scan = NULL;
 	}
-- 
2.2.2

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

* [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (27 preceding siblings ...)
  2015-02-04 17:54                                   ` [PATCH] ath9k: Delete an unnecessary check before the function call "relay_close" SF Markus Elfring
@ 2015-02-04 18:33                                   ` SF Markus Elfring
  2015-03-04 12:06                                     ` Kalle Valo
  2015-02-04 18:56                                   ` [PATCH] orinoco: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
                                                     ` (25 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 18:33 UTC (permalink / raw)
  To: Kalle Valo, ath10k, linux-wireless, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 19:30:23 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/ath/ath10k/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
index 2d0671e..45171ad 100644
--- a/drivers/net/wireless/ath/ath10k/core.c
+++ b/drivers/net/wireless/ath/ath10k/core.c
@@ -393,16 +393,16 @@ static int ath10k_download_fw(struct ath10k *ar, enum ath10k_firmware_mode mode)
 
 static void ath10k_core_free_firmware_files(struct ath10k *ar)
 {
-	if (ar->board && !IS_ERR(ar->board))
+	if (!IS_ERR(ar->board))
 		release_firmware(ar->board);
 
-	if (ar->otp && !IS_ERR(ar->otp))
+	if (!IS_ERR(ar->otp))
 		release_firmware(ar->otp);
 
-	if (ar->firmware && !IS_ERR(ar->firmware))
+	if (!IS_ERR(ar->firmware))
 		release_firmware(ar->firmware);
 
-	if (ar->cal_file && !IS_ERR(ar->cal_file))
+	if (!IS_ERR(ar->cal_file))
 		release_firmware(ar->cal_file);
 
 	ar->board = NULL;
-- 
2.2.2

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

* [PATCH] orinoco: Delete an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (28 preceding siblings ...)
  2015-02-04 18:33                                   ` [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware" SF Markus Elfring
@ 2015-02-04 18:56                                   ` SF Markus Elfring
  2015-02-06  6:51                                     ` Kalle Valo
  2015-02-04 19:10                                   ` [PATCH] HostAP: " SF Markus Elfring
                                                     ` (24 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 18:56 UTC (permalink / raw)
  To: Kalle Valo, linux-wireless, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 19:53:11 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/orinoco/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 38ec8d1..c410180 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -2342,7 +2342,7 @@ void free_orinocodev(struct orinoco_private *priv)
 	list_for_each_entry_safe(sd, sdtemp, &priv->scan_list, list) {
 		list_del(&sd->list);
 
-		if ((sd->len > 0) && sd->buf)
+		if (sd->len > 0)
 			kfree(sd->buf);
 		kfree(sd);
 	}
-- 
2.2.2

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

* [PATCH] HostAP: Delete an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (29 preceding siblings ...)
  2015-02-04 18:56                                   ` [PATCH] orinoco: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-02-04 19:10                                   ` SF Markus Elfring
  2015-02-06  6:52                                     ` hostap: " Kalle Valo
  2015-02-04 19:40                                   ` [PATCH] net: brcm80211: Delete unnecessary checks before two function calls SF Markus Elfring
                                                     ` (23 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 19:10 UTC (permalink / raw)
  To: Jouni Malinen, Kalle Valo, linux-wireless, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 20:06:39 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/hostap/hostap_ap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 5965255..fd8d83d 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -145,7 +145,7 @@ static void ap_free_sta(struct ap_data *ap, struct sta_info *sta)
 	if (sta->aid > 0)
 		ap->sta_aid[sta->aid - 1] = NULL;
 
-	if (!sta->ap && sta->u.sta.challenge)
+	if (!sta->ap)
 		kfree(sta->u.sta.challenge);
 	del_timer_sync(&sta->timer);
 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
-- 
2.2.2

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

* [PATCH] net: brcm80211: Delete unnecessary checks before two function calls
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (30 preceding siblings ...)
  2015-02-04 19:10                                   ` [PATCH] HostAP: " SF Markus Elfring
@ 2015-02-04 19:40                                   ` SF Markus Elfring
  2015-02-06  6:53                                     ` Kalle Valo
  2015-06-29 10:48                                   ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
                                                     ` (22 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-04 19:40 UTC (permalink / raw)
  To: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, Kalle Valo, brcm80211-dev-list, linux-wireless,
	netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 4 Feb 2015 20:28:49 +0100

The functions brcmu_pkt_buf_free_skb() and usb_free_urb() test whether
their argument is NULL and then return immediately. Thus the test around
the call is not needed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 3 +--
 drivers/net/wireless/brcm80211/brcmfmac/usb.c  | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio.c
index 99a3776..5b5520b 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio.c
@@ -2543,8 +2543,7 @@ static void brcmf_sdio_bus_stop(struct device *dev)
 	brcmu_pktq_flush(&bus->txq, true, NULL, NULL);
 
 	/* Clear any held glomming stuff */
-	if (bus->glomd)
-		brcmu_pkt_buf_free_skb(bus->glomd);
+	brcmu_pkt_buf_free_skb(bus->glomd);
 	brcmf_sdio_free_glom(bus);
 
 	/* Clear rx control and wake any waiters */
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index 4572def..10c684c 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -421,7 +421,7 @@ fail:
 	brcmf_err("fail!\n");
 	while (!list_empty(q)) {
 		req = list_entry(q->next, struct brcmf_usbreq, list);
-		if (req && req->urb)
+		if (req)
 			usb_free_urb(req->urb);
 		list_del(q->next);
 	}
-- 
2.2.2

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

* Re: [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put"
  2015-02-03 18:51                                   ` [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put" SF Markus Elfring
@ 2015-02-05  4:29                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  4:29 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 03 Feb 2015 19:51:38 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 3 Feb 2015 19:47:33 +0100
> 
> The of_dev_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
  2015-02-03 19:22                                   ` [PATCH] NetCP: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2015-02-05  4:30                                     ` David Miller
  2015-02-05 12:01                                     ` Dan Carpenter
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  4:30 UTC (permalink / raw)
  To: elfring
  Cc: m-karicheri2, w-kwok2, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 03 Feb 2015 20:22:23 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 3 Feb 2015 20:12:25 +0100
> 
> The functions cpsw_ale_destroy() and of_dev_put() test whether their argument
> is NULL and then return immediately. Thus the test around the call
> is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware"
  2015-02-04 10:38                                   ` [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2015-02-05  8:07                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  8:07 UTC (permalink / raw)
  To: elfring; +Cc: hariprasad, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 04 Feb 2015 11:38:39 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 11:28:43 +0100
> 
> The release_firmware() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree"
  2015-02-04 11:36                                   ` [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-02-05  8:25                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  8:25 UTC (permalink / raw)
  To: elfring; +Cc: hykim, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 04 Feb 2015 12:36:02 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 12:32:14 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] net: fec: Delete unnecessary checks before the function call "kfree"
  2015-02-04 12:00                                   ` [PATCH] net: fec: Delete unnecessary checks " SF Markus Elfring
@ 2015-02-05  8:26                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  8:26 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 04 Feb 2015 13:00:46 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 12:56:42 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] netxen: Delete an unnecessary check before the function call "kfree"
  2015-02-04 12:21                                   ` [PATCH] netxen: Delete an unnecessary check " SF Markus Elfring
@ 2015-02-05  8:26                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  8:26 UTC (permalink / raw)
  To: elfring
  Cc: manish.chopra, rajesh.borundia, sony.chacko, netdev,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 04 Feb 2015 13:21:29 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 13:17:48 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] qlogic: Deletion of unnecessary checks before two function calls
  2015-02-04 13:13                                   ` [PATCH] qlogic: Deletion of unnecessary checks before two function calls SF Markus Elfring
@ 2015-02-05  8:33                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  8:33 UTC (permalink / raw)
  To: elfring
  Cc: shahed.shaikh, Dept-GELinuxNICDev, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 04 Feb 2015 14:13:37 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 14:07:56 +0100
> 
> The functions kfree() and vfree() perform also input parameter validation.
> Thus the test around their calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
       [not found]                                     ` <54D22B29.3020200-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-02-05  8:34                                       ` David Miller
       [not found]                                         ` <20150205.003404.261962007607296519.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 273+ messages in thread
From: David Miller @ 2015-02-05  8:34 UTC (permalink / raw)
  To: elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f
  Cc: eli-VPRAkNaXOzVWk0Htik3J/w, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, julia.lawall-L2FTfq7BK8M

From: SF Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Wed, 04 Feb 2015 15:22:33 +0100

> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Wed, 4 Feb 2015 15:17:00 +0100
> 
> The vunmap() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>

This does not apply cleanly to the net-next tree, please respin.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree"
  2015-02-04 15:00                                   ` [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree" SF Markus Elfring
  2015-02-04 15:59                                     ` Hartley Sweeten
@ 2015-02-05  8:37                                     ` David Miller
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-05  8:37 UTC (permalink / raw)
  To: elfring; +Cc: hsweeten, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 04 Feb 2015 16:00:37 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 15:56:58 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
  2015-02-03 19:22                                   ` [PATCH] NetCP: Deletion of unnecessary checks before two function calls SF Markus Elfring
  2015-02-05  4:30                                     ` David Miller
@ 2015-02-05 12:01                                     ` Dan Carpenter
  2015-02-05 15:50                                       ` Kwok, WingMan
  1 sibling, 1 reply; 273+ messages in thread
From: Dan Carpenter @ 2015-02-05 12:01 UTC (permalink / raw)
  To: Wingman Kwok
  Cc: SF Markus Elfring, Murali Karicheri, Wingman Kwok, netdev, LKML,
	kernel-janitors, Julia Lawall

Hi Wingman,

There are some bugs in this error handling.

On Tue, Feb 03, 2015 at 08:22:23PM +0100, SF Markus Elfring wrote:
> diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
> index fa1041a..cbd6dde 100644
> --- a/drivers/net/ethernet/ti/netcp_ethss.c
> +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> @@ -2010,12 +2010,10 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
>  quit:
>  	if (gbe_dev->hw_stats)
>  		devm_kfree(dev, gbe_dev->hw_stats);
> -	if (gbe_dev->ale)
> -		cpsw_ale_destroy(gbe_dev->ale);
> +	cpsw_ale_destroy(gbe_dev->ale);
>  	if (gbe_dev->ss_regs)
>  		devm_iounmap(dev, gbe_dev->ss_regs);
> -	if (interfaces)
> -		of_node_put(interfaces);
> +	of_node_put(interfaces);
                    ^^^^^^^^^^
"interfaces" is sometimes unintialized in this code.  I don't know why
GCC doesn't catch this...  :(

This is a "one rrr bug", which is caused because you just have one error
label "quit" which handles all the error handling.  Please read my
Google+ comment on error handling.

https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ

>  	devm_kfree(dev, gbe_dev);
        ^^^^^^^^^^^^^^^^^^^^^^^^
This is not the right way to use the devm_ interface.  These things are
freed automatically on error or when we are done with them.  This driver
is double freeing pretty much everything.  Grep for devm_kfree() and
fix everything.

I don't know why kbuild didn't catch this...

regards
dan carpenter

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

* RE: [PATCH] NetCP: Deletion of unnecessary checks before two function calls
  2015-02-05 12:01                                     ` Dan Carpenter
@ 2015-02-05 15:50                                       ` Kwok, WingMan
  0 siblings, 0 replies; 273+ messages in thread
From: Kwok, WingMan @ 2015-02-05 15:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Karicheri, Muralidharan, netdev, LKML,
	kernel-janitors, Julia Lawall

Dan,

Thanks.  We'll look into it and send a patch soon.

Regards,
WingMan

> -----Original Message-----
> From: Dan Carpenter [mailto:dan.carpenter@oracle.com]
> Sent: Thursday, February 05, 2015 7:02 AM
> To: Kwok, WingMan
> Cc: SF Markus Elfring; Karicheri, Muralidharan; Kwok, WingMan;
> netdev@vger.kernel.org; LKML; kernel-janitors@vger.kernel.org; Julia Lawall
> Subject: Re: [PATCH] NetCP: Deletion of unnecessary checks before two
> function calls
> 
> Hi Wingman,
> 
> There are some bugs in this error handling.
> 
> On Tue, Feb 03, 2015 at 08:22:23PM +0100, SF Markus Elfring wrote:
> > diff --git a/drivers/net/ethernet/ti/netcp_ethss.c
> b/drivers/net/ethernet/ti/netcp_ethss.c
> > index fa1041a..cbd6dde 100644
> > --- a/drivers/net/ethernet/ti/netcp_ethss.c
> > +++ b/drivers/net/ethernet/ti/netcp_ethss.c
> > @@ -2010,12 +2010,10 @@ static int gbe_probe(struct netcp_device
> *netcp_device, struct device *dev,
> >  quit:
> >  	if (gbe_dev->hw_stats)
> >  		devm_kfree(dev, gbe_dev->hw_stats);
> > -	if (gbe_dev->ale)
> > -		cpsw_ale_destroy(gbe_dev->ale);
> > +	cpsw_ale_destroy(gbe_dev->ale);
> >  	if (gbe_dev->ss_regs)
> >  		devm_iounmap(dev, gbe_dev->ss_regs);
> > -	if (interfaces)
> > -		of_node_put(interfaces);
> > +	of_node_put(interfaces);
>                     ^^^^^^^^^^
> "interfaces" is sometimes unintialized in this code.  I don't know why
> GCC doesn't catch this...  :(
> 
> This is a "one rrr bug", which is caused because you just have one error
> label "quit" which handles all the error handling.  Please read my
> Google+ comment on error handling.
> 
> https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
> 
> >  	devm_kfree(dev, gbe_dev);
>         ^^^^^^^^^^^^^^^^^^^^^^^^
> This is not the right way to use the devm_ interface.  These things are
> freed automatically on error or when we are done with them.  This driver
> is double freeing pretty much everything.  Grep for devm_kfree() and
> fix everything.
> 
> I don't know why kbuild didn't catch this...
> 
> regards
> dan carpenter


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

* Re: [1/2] cw1200: Delete an unnecessary check before the function call "release_firmware"
  2015-02-04 16:47                                     ` [PATCH 1/2] CW1200: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2015-02-06  6:49                                       ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-02-06  6:49 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Solomon Peachy, netdev, linux-wireless, LKML, kernel-janitors,
	Julia Lawall


> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 16:32:15 +0100
> 
> The release_firmware() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, 2 patches applied to wireless-drivers-next.git:

df970d39b90e cw1200: Delete an unnecessary check before the function call "release_firmware"
ee4ddad82356 cw1200: Less function calls in cw1200_load_firmware_cw1200() after error detection

Kalle Valo

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

* Re: ath9k: Delete an unnecessary check before the function call"relay_close"
  2015-02-04 17:54                                   ` [PATCH] ath9k: Delete an unnecessary check before the function call "relay_close" SF Markus Elfring
@ 2015-02-06  6:50                                     ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-02-06  6:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: ath9k-devel, linux-wireless, QCA ath9k Development, netdev, LKML,
	kernel-janitors, Julia Lawall


> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 18:48:28 +0100
> 
> The relay_close() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

* Re: orinoco: Delete an unnecessary check before the function call "kfree"
  2015-02-04 18:56                                   ` [PATCH] orinoco: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-02-06  6:51                                     ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-02-06  6:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, LKML, kernel-janitors, Julia Lawall


> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 19:53:11 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

* Re: hostap: Delete an unnecessary check before the function call "kfree"
  2015-02-04 19:10                                   ` [PATCH] HostAP: " SF Markus Elfring
@ 2015-02-06  6:52                                     ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-02-06  6:52 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jouni Malinen, linux-wireless, netdev, LKML, kernel-janitors,
	Julia Lawall


> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 20:06:39 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

* Re: brcm80211: Delete unnecessary checks before two function calls
  2015-02-04 19:40                                   ` [PATCH] net: brcm80211: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-02-06  6:53                                     ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-02-06  6:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, brcm80211-dev-list, linux-wireless, netdev, LKML,
	kernel-janitors, Julia Lawall


> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 20:28:49 +0100
> 
> The functions brcmu_pkt_buf_free_skb() and usb_free_urb() test whether
> their argument is NULL and then return immediately. Thus the test around
> the call is not needed.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

* [PATCH v2] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
       [not found]                                         ` <20150205.003404.261962007607296519.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
@ 2015-02-09 10:21                                           ` SF Markus Elfring
  2015-02-09 22:10                                             ` David Miller
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-02-09 10:21 UTC (permalink / raw)
  To: David Miller
  Cc: Eli Cohen, netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Mon, 9 Feb 2015 11:10:41 +0100

The vunmap() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Acked-by: Eli Cohen <eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
 drivers/net/ethernet/mellanox/mlx4/alloc.c      | 2 +-
 drivers/net/ethernet/mellanox/mlx5/core/alloc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c
index a716c26..0c51c69 100644
--- a/drivers/net/ethernet/mellanox/mlx4/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c
@@ -662,7 +662,7 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf)
 				  buf->direct.buf,
 				  buf->direct.map);
 	else {
-		if (BITS_PER_LONG == 64 && buf->direct.buf)
+		if (BITS_PER_LONG == 64)
 			vunmap(buf->direct.buf);
 
 		for (i = 0; i < buf->nbufs; ++i)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
index 56779c1..201ca6d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/alloc.c
@@ -121,7 +121,7 @@ void mlx5_buf_free(struct mlx5_core_dev *dev, struct mlx5_buf *buf)
 		dma_free_coherent(&dev->pdev->dev, buf->size, buf->direct.buf,
 				  buf->direct.map);
 	else {
-		if (BITS_PER_LONG == 64 && buf->direct.buf)
+		if (BITS_PER_LONG == 64)
 			vunmap(buf->direct.buf);
 
 		for (i = 0; i < buf->nbufs; i++)
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] net: Mellanox: Delete unnecessary checks before the function call "vunmap"
  2015-02-09 10:21                                           ` [PATCH v2] " SF Markus Elfring
@ 2015-02-09 22:10                                             ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-02-09 22:10 UTC (permalink / raw)
  To: elfring
  Cc: eli, netdev, linux-rdma, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 09 Feb 2015 11:21:26 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 9 Feb 2015 11:10:41 +0100
> 
> The vunmap() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> Acked-by: Eli Cohen <eli@mellanox.com>

Applied.

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

* Re: [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware"
  2015-02-04 18:33                                   ` [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware" SF Markus Elfring
@ 2015-03-04 12:06                                     ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-03-04 12:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: ath10k, linux-wireless, netdev, Julia Lawall, kernel-janitors, LKML

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 4 Feb 2015 19:30:23 +0100
>
> The release_firmware() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied to ath.git.

-- 
Kalle Valo

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

* [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (31 preceding siblings ...)
  2015-02-04 19:40                                   ` [PATCH] net: brcm80211: Delete unnecessary checks before two function calls SF Markus Elfring
@ 2015-06-29 10:48                                   ` SF Markus Elfring
  2015-06-29 16:28                                     ` David Miller
  2015-07-02 14:43                                   ` [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu" SF Markus Elfring
                                                     ` (21 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-06-29 10:48 UTC (permalink / raw)
  To: Derek Chickles, Felix Manlunas, Raghu Vatsavayi, Robert Richter,
	Satanand Burla, Sunil Goutham, netdev, linux-arm-kernel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Jun 2015 12:22:24 +0200

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/cavium/liquidio/octeon_device.c   | 11 +++--------
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c     |  4 +---
 drivers/net/ethernet/cavium/liquidio/request_manager.c |  3 +--
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index 0d3106b..f67641a 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -650,14 +650,12 @@ void octeon_free_device_mem(struct octeon_device *oct)
 
 	for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES; i++) {
 		/* could check  mask as well */
-		if (oct->droq[i])
-			vfree(oct->droq[i]);
+		vfree(oct->droq[i]);
 	}
 
 	for (i = 0; i < MAX_OCTEON_INSTR_QUEUES; i++) {
 		/* could check mask as well */
-		if (oct->instr_queue[i])
-			vfree(oct->instr_queue[i]);
+		vfree(oct->instr_queue[i]);
 	}
 
 	i = oct->octeon_id;
@@ -1078,10 +1076,7 @@ octeon_unregister_dispatch_fn(struct octeon_device *oct, u16 opcode,
 		oct->dispatch.count--;
 
 	spin_unlock_bh(&oct->dispatch.lock);
-
-	if (dfree)
-		vfree(dfree);
-
+	vfree(dfree);
 	return retval;
 }
 
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
index 94b502a..4dba86e 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
@@ -216,9 +216,7 @@ int octeon_delete_droq(struct octeon_device *oct, u32 q_no)
 	dev_dbg(&oct->pci_dev->dev, "%s[%d]\n", __func__, q_no);
 
 	octeon_droq_destroy_ring_buffers(oct, droq);
-
-	if (droq->recv_buf_list)
-		vfree(droq->recv_buf_list);
+	vfree(droq->recv_buf_list);
 
 	if (droq->info_base_addr)
 		cnnic_free_aligned_dma(oct->pci_dev, droq->info_list,
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index 356796b..a2a2465 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -175,8 +175,7 @@ int octeon_delete_instr_queue(struct octeon_device *oct, u32 iq_no)
 		desc_size =
 		    CFG_GET_IQ_INSTR_TYPE(CHIP_FIELD(oct, cn6xxx, conf));
 
-	if (iq->request_list)
-		vfree(iq->request_list);
+	vfree(iq->request_list);
 
 	if (iq->base_addr) {
 		q_size = iq->max_count * desc_size;
-- 
2.4.5

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

* Re: [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree"
  2015-06-29 10:48                                   ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2015-06-29 16:28                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-06-29 16:28 UTC (permalink / raw)
  To: elfring
  Cc: derek.chickles, felix.manlunas, raghu.vatsavayi, rric,
	satananda.burla, sgoutham, netdev, linux-arm-kernel,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Jun 2015 12:48:16 +0200

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 29 Jun 2015 12:22:24 +0200
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (32 preceding siblings ...)
  2015-06-29 10:48                                   ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
@ 2015-07-02 14:43                                   ` SF Markus Elfring
  2015-07-03 16:28                                     ` David Miller
  2015-07-02 16:08                                   ` [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
                                                     ` (20 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-07-02 14:43 UTC (permalink / raw)
  To: Alexey Kuznetsov, David S. Miller, Hideaki YOSHIFUJI,
	James Morris, Patrick McHardy, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Jul 2015 16:30:24 +0200

The free_percpu() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/ipv6/route.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1a1122a..6090969 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -369,10 +369,7 @@ static void ip6_dst_destroy(struct dst_entry *dst)
 	struct inet6_dev *idev;
 
 	dst_destroy_metrics_generic(dst);
-
-	if (rt->rt6i_pcpu)
-		free_percpu(rt->rt6i_pcpu);
-
+	free_percpu(rt->rt6i_pcpu);
 	rt6_uncached_list_del(rt);
 
 	idev = rt->rt6i_idev;
-- 
2.4.5

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

* [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put"
  2014-11-19 13:40                                     ` Pablo Neira Ayuso
@ 2015-07-02 15:10                                       ` SF Markus Elfring
  2015-07-09  1:41                                         ` Simon Horman
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-07-02 15:10 UTC (permalink / raw)
  To: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Pablo Neira Ayuso, Patrick McHardy, Simon Horman, Wensong Zhang,
	netdev, lvs-devel, netfilter-devel, coreteam
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Jul 2015 17:00:14 +0200

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netfilter/ipvs/ip_vs_sched.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/ipvs/ip_vs_sched.c b/net/netfilter/ipvs/ip_vs_sched.c
index 199760c..e50221b 100644
--- a/net/netfilter/ipvs/ip_vs_sched.c
+++ b/net/netfilter/ipvs/ip_vs_sched.c
@@ -137,7 +137,7 @@ struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name)
 
 void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
 {
-	if (scheduler && scheduler->module)
+	if (scheduler)
 		module_put(scheduler->module);
 }
 
-- 
2.4.5


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

* [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (33 preceding siblings ...)
  2015-07-02 14:43                                   ` [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu" SF Markus Elfring
@ 2015-07-02 16:08                                   ` SF Markus Elfring
  2015-07-03 16:28                                     ` David Miller
  2015-07-02 16:45                                   ` [PATCH] netlink: " SF Markus Elfring
                                                     ` (19 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-07-02 16:08 UTC (permalink / raw)
  To: Chien Yen, David S. Miller, rds-devel, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Jul 2015 17:58:21 +0200

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/rds/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rds/transport.c b/net/rds/transport.c
index 8b4a6cd..83498e1 100644
--- a/net/rds/transport.c
+++ b/net/rds/transport.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(rds_trans_unregister);
 
 void rds_trans_put(struct rds_transport *trans)
 {
-	if (trans && trans->t_owner)
+	if (trans)
 		module_put(trans->t_owner);
 }
 
-- 
2.4.5

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

* [PATCH] netlink: Delete an unnecessary check before the function call "module_put"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (34 preceding siblings ...)
  2015-07-02 16:08                                   ` [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
@ 2015-07-02 16:45                                   ` SF Markus Elfring
  2015-07-03 16:28                                     ` David Miller
  2015-11-03 17:30                                   ` [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service" SF Markus Elfring
                                                     ` (18 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-07-02 16:45 UTC (permalink / raw)
  To: David S. Miller, netdev
  Cc: Linux Kernel Mailing List, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Jul 2015 18:38:12 +0200

The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/netlink/af_netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index dea9253..9a0ae71 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -158,7 +158,7 @@ static int __netlink_remove_tap(struct netlink_tap *nt)
 out:
 	spin_unlock(&netlink_tap_lock);
 
-	if (found && nt->module)
+	if (found)
 		module_put(nt->module);
 
 	return found ? 0 : -ENODEV;
-- 
2.4.5


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

* Re: [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu"
  2015-07-02 14:43                                   ` [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu" SF Markus Elfring
@ 2015-07-03 16:28                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-07-03 16:28 UTC (permalink / raw)
  To: elfring
  Cc: kuznet, yoshfuji, jmorris, kaber, netdev, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 02 Jul 2015 16:43:43 +0200

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 2 Jul 2015 16:30:24 +0200
> 
> The free_percpu() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put"
  2015-07-02 16:08                                   ` [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
@ 2015-07-03 16:28                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-07-03 16:28 UTC (permalink / raw)
  To: elfring
  Cc: chien.yen, rds-devel, netdev, linux-kernel, kernel-janitors,
	julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 02 Jul 2015 18:08:19 +0200

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 2 Jul 2015 17:58:21 +0200
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] netlink: Delete an unnecessary check before the function call "module_put"
  2015-07-02 16:45                                   ` [PATCH] netlink: " SF Markus Elfring
@ 2015-07-03 16:28                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-07-03 16:28 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 02 Jul 2015 18:45:53 +0200

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 2 Jul 2015 18:38:12 +0200
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put"
  2015-07-02 15:10                                       ` [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
@ 2015-07-09  1:41                                         ` Simon Horman
  0 siblings, 0 replies; 273+ messages in thread
From: Simon Horman @ 2015-07-09  1:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Jozsef Kadlecsik, Julian Anastasov,
	Pablo Neira Ayuso, Patrick McHardy, Wensong Zhang, netdev,
	lvs-devel, netfilter-devel, coreteam, LKML, kernel-janitors,
	Julia Lawall

On Thu, Jul 02, 2015 at 05:10:41PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 2 Jul 2015 17:00:14 +0200
> 
> The module_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.

Thanks, applied to ipvs-next for v4.3.

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

* [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (35 preceding siblings ...)
  2015-07-02 16:45                                   ` [PATCH] netlink: " SF Markus Elfring
@ 2015-11-03 17:30                                   ` SF Markus Elfring
  2015-11-03 18:31                                     ` David Miller
  2015-11-03 20:45                                   ` [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks SF Markus Elfring
                                                     ` (17 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-03 17:30 UTC (permalink / raw)
  To: David S. Miller, Samuel Ortiz, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Nov 2015 18:18:37 +0100

The irlmp_unregister_service() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/irda/af_irda.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index fae6822..e6aa48b 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -2123,8 +2123,7 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
 		}
 
 		/* Unregister any old registration */
-		if (self->skey)
-			irlmp_unregister_service(self->skey);
+		irlmp_unregister_service(self->skey);
 
 		self->skey = irlmp_register_service((__u16) opt);
 		break;
-- 
2.6.2

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

* Re: [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service"
  2015-11-03 17:30                                   ` [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service" SF Markus Elfring
@ 2015-11-03 18:31                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-11-03 18:31 UTC (permalink / raw)
  To: elfring; +Cc: samuel, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Nov 2015 18:30:58 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 3 Nov 2015 18:18:37 +0100
> 
> The irlmp_unregister_service() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (36 preceding siblings ...)
  2015-11-03 17:30                                   ` [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service" SF Markus Elfring
@ 2015-11-03 20:45                                   ` SF Markus Elfring
  2015-11-03 20:52                                     ` [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref" SF Markus Elfring
                                                       ` (2 more replies)
  2015-11-06  7:15                                   ` [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
                                                     ` (16 subsequent siblings)
  54 siblings, 3 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-03 20:45 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Nov 2015 21:34:29 +0100

Further update suggestions were taken into account after a patch
was applied from static source code analysis.

Markus Elfring (3):
  Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref"
  Split a condition check
  Less function calls in batadv_is_ap_isolated() after error detection

 net/batman-adv/translation-table.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

-- 
2.6.2

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

* [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref"
  2015-11-03 20:45                                   ` [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-11-03 20:52                                     ` SF Markus Elfring
  2015-11-21 21:48                                       ` [B.A.T.M.A.N.] " Marek Lindner
  2015-11-03 20:54                                     ` [PATCH 2/3] batman-adv: Split a condition check SF Markus Elfring
  2015-11-03 20:56                                     ` [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection SF Markus Elfring
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-03 20:52 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Nov 2015 19:20:34 +0100

The batadv_softif_vlan_free_ref() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/translation-table.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 4228b10..48315de 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3336,8 +3336,7 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 	ret = true;
 
 out:
-	if (vlan)
-		batadv_softif_vlan_free_ref(vlan);
+	batadv_softif_vlan_free_ref(vlan);
 	if (tt_global_entry)
 		batadv_tt_global_entry_free_ref(tt_global_entry);
 	if (tt_local_entry)
-- 
2.6.2

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

* [PATCH 2/3] batman-adv: Split a condition check
  2015-11-03 20:45                                   ` [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks SF Markus Elfring
  2015-11-03 20:52                                     ` [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref" SF Markus Elfring
@ 2015-11-03 20:54                                     ` SF Markus Elfring
  2015-11-21 21:51                                       ` [B.A.T.M.A.N.] " Marek Lindner
  2015-11-03 20:56                                     ` [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection SF Markus Elfring
  2 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-03 20:54 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Nov 2015 20:41:02 +0100

Let us split a check for a condition at the beginning of the
batadv_is_ap_isolated() function so that a direct return can be performed
in this function if the variable "vlan" contained a null pointer.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/translation-table.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 48315de..965a004 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3319,7 +3319,10 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 	bool ret = false;
 
 	vlan = batadv_softif_vlan_get(bat_priv, vid);
-	if (!vlan || !atomic_read(&vlan->ap_isolation))
+	if (!vlan)
+		return false;
+
+	if (!atomic_read(&vlan->ap_isolation))
 		goto out;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
-- 
2.6.2

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

* [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
  2015-11-03 20:45                                   ` [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks SF Markus Elfring
  2015-11-03 20:52                                     ` [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref" SF Markus Elfring
  2015-11-03 20:54                                     ` [PATCH 2/3] batman-adv: Split a condition check SF Markus Elfring
@ 2015-11-03 20:56                                     ` SF Markus Elfring
  2015-11-20  8:47                                       ` [B.A.T.M.A.N.] " Antonio Quartulli
       [not found]                                       ` <564EDE1D.7070809@meshcoding.com>
  2 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-03 20:56 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 3 Nov 2015 21:10:51 +0100

The variables "tt_local_entry" and "tt_global_entry" were eventually checked
again despite of a corresponding null pointer test before.
Let us avoid this double check by reordering a function call sequence
and the better selection of jump targets.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/translation-table.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 965a004..3ac32d9 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3323,27 +3323,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 		return false;
 
 	if (!atomic_read(&vlan->ap_isolation))
-		goto out;
+		goto vlan_free;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
 	if (!tt_local_entry)
-		goto out;
+		goto vlan_free;
 
 	tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
 	if (!tt_global_entry)
-		goto out;
+		goto local_entry_free;
 
-	if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
-		goto out;
-
-	ret = true;
+	if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
+		ret = true;
 
-out:
+	batadv_tt_global_entry_free_ref(tt_global_entry);
+local_entry_free:
+	batadv_tt_local_entry_free_ref(tt_local_entry);
+vlan_free:
 	batadv_softif_vlan_free_ref(vlan);
-	if (tt_global_entry)
-		batadv_tt_global_entry_free_ref(tt_global_entry);
-	if (tt_local_entry)
-		batadv_tt_local_entry_free_ref(tt_local_entry);
 	return ret;
 }
 
-- 
2.6.2


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

* [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (37 preceding siblings ...)
  2015-11-03 20:45                                   ` [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks SF Markus Elfring
@ 2015-11-06  7:15                                   ` SF Markus Elfring
  2015-11-07  4:33                                     ` David Miller
  2015-11-06  8:39                                   ` [PATCH] fjes: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
                                                     ` (15 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-06  7:15 UTC (permalink / raw)
  To: Lars Persson, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 08:00:22 +0100

The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/synopsys/dwc_eth_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 85b3326..9066d7a 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -2970,8 +2970,7 @@ err_out_unregister_netdev:
 err_out_clk_dis_aper:
 	clk_disable_unprepare(lp->apb_pclk);
 err_out_free_netdev:
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	free_netdev(ndev);
 	platform_set_drvdata(pdev, NULL);
 	return ret;
-- 
2.6.2

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

* [PATCH] net: brcm80211: Delete an unnecessary check before the function call "release_firmware"
  2014-11-20 18:04                                     ` Arend van Spriel
@ 2015-11-06  7:58                                       ` SF Markus Elfring
  2015-11-11  9:18                                         ` Arend van Spriel
       [not found]                                         ` <563C5DA2.3000005-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  0 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-06  7:58 UTC (permalink / raw)
  To: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, Kalle Valo, brcm80211-dev-list, linux-wireless,
	netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 08:48:23 +0100

The release_firmware() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index 4248f3c..33afb9a 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -449,8 +449,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 
 	if (raw_nvram)
 		bcm47xx_nvram_release_contents(data);
-	if (fw)
-		release_firmware(fw);
+	release_firmware(fw);
 	if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
 		goto fail;
 
-- 
2.6.2

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

* [PATCH] fjes: Delete an unnecessary check before the function call "vfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (38 preceding siblings ...)
  2015-11-06  7:15                                   ` [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
@ 2015-11-06  8:39                                   ` SF Markus Elfring
  2015-11-07 18:18                                     ` David Miller
  2015-11-14 17:12                                   ` [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device" SF Markus Elfring
                                                     ` (14 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-06  8:39 UTC (permalink / raw)
  To: Taku Izumi, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 09:30:29 +0100

The vfree() function performs also input parameter validation.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/fjes/fjes_hw.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/fjes/fjes_hw.c b/drivers/net/fjes/fjes_hw.c
index 2d3848c..bb8b530 100644
--- a/drivers/net/fjes/fjes_hw.c
+++ b/drivers/net/fjes/fjes_hw.c
@@ -143,9 +143,7 @@ static int fjes_hw_alloc_epbuf(struct epbuf_handler *epbh)
 
 static void fjes_hw_free_epbuf(struct epbuf_handler *epbh)
 {
-	if (epbh->buffer)
-		vfree(epbh->buffer);
-
+	vfree(epbh->buffer);
 	epbh->buffer = NULL;
 	epbh->size = 0;
 
-- 
2.6.2

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

* Re: [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put"
  2015-11-06  7:15                                   ` [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
@ 2015-11-07  4:33                                     ` David Miller
  2015-11-07 14:15                                       ` [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put() SF Markus Elfring
  2015-11-07 15:34                                       ` [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
  0 siblings, 2 replies; 273+ messages in thread
From: David Miller @ 2015-11-07  4:33 UTC (permalink / raw)
  To: elfring; +Cc: lars.persson, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 08:15:30 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 6 Nov 2015 08:00:22 +0100
> 
> The of_node_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Please resubmit this with a more appropriate Subject line.

The subsystem prefix should be all lower-case and typically
indicate the most specific subsystem or area being changed.

In this case it's a driver, therefore simply use the driver
name "dwc_eth_qos: ".

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

* [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put()
  2015-11-07  4:33                                     ` David Miller
@ 2015-11-07 14:15                                       ` SF Markus Elfring
  2015-11-07 14:50                                         ` David Miller
  2015-11-07 15:34                                       ` [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-07 14:15 UTC (permalink / raw)
  To: David Miller, Lars Persson, netdev
  Cc: linux-kernel, kernel-janitors, julia.lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 7 Nov 2015 15:10:29 +0100

The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/synopsys/dwc_eth_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 85b3326..9066d7a 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -2970,8 +2970,7 @@ err_out_unregister_netdev:
 err_out_clk_dis_aper:
 	clk_disable_unprepare(lp->apb_pclk);
 err_out_free_netdev:
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	free_netdev(ndev);
 	platform_set_drvdata(pdev, NULL);
 	return ret;
-- 
2.6.2

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

* Re: [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put()
  2015-11-07 14:15                                       ` [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put() SF Markus Elfring
@ 2015-11-07 14:50                                         ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-11-07 14:50 UTC (permalink / raw)
  To: elfring; +Cc: lars.persson, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 7 Nov 2015 15:15:24 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 7 Nov 2015 15:10:29 +0100
> 
> The of_node_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

As I requested of you last night, please phrase the subsystem
prefix of your Subject lines more correctly.

Just use the driver's name, in lower case, as one single word,
which in this case would be "dwc_eth_qos: ".

I'm telling you exactly what to use in the Subject line, there
is no ambiguity or confusion on what you need to do for me to
accept this patch.

Thanks.

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

* [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put"
  2015-11-07  4:33                                     ` David Miller
  2015-11-07 14:15                                       ` [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put() SF Markus Elfring
@ 2015-11-07 15:34                                       ` SF Markus Elfring
  2015-11-07 18:19                                         ` David Miller
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-07 15:34 UTC (permalink / raw)
  To: David Miller, Lars Persson, netdev
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 7 Nov 2015 16:30:34 +0100

The of_node_put() function tests whether its argument is NULL
and then returns immediately.
Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/synopsys/dwc_eth_qos.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
index 85b3326..9066d7a 100644
--- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c
+++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c
@@ -2970,8 +2970,7 @@ err_out_unregister_netdev:
 err_out_clk_dis_aper:
 	clk_disable_unprepare(lp->apb_pclk);
 err_out_free_netdev:
-	if (lp->phy_node)
-		of_node_put(lp->phy_node);
+	of_node_put(lp->phy_node);
 	free_netdev(ndev);
 	platform_set_drvdata(pdev, NULL);
 	return ret;
-- 
2.6.2


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

* Re: [PATCH] fjes: Delete an unnecessary check before the function call "vfree"
  2015-11-06  8:39                                   ` [PATCH] fjes: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2015-11-07 18:18                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-11-07 18:18 UTC (permalink / raw)
  To: elfring; +Cc: izumi.taku, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 09:39:23 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 6 Nov 2015 09:30:29 +0100
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put"
  2015-11-07 15:34                                       ` [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
@ 2015-11-07 18:19                                         ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-11-07 18:19 UTC (permalink / raw)
  To: elfring; +Cc: lars.persson, netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 7 Nov 2015 16:34:48 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 7 Nov 2015 16:30:34 +0100
> 
> The of_node_put() function tests whether its argument is NULL
> and then returns immediately.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

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

* Re: [PATCH] net: brcm80211: Delete an unnecessary check before the function call "release_firmware"
  2015-11-06  7:58                                       ` [PATCH] net: brcm80211: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
@ 2015-11-11  9:18                                         ` Arend van Spriel
       [not found]                                         ` <563C5DA2.3000005-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  1 sibling, 0 replies; 273+ messages in thread
From: Arend van Spriel @ 2015-11-11  9:18 UTC (permalink / raw)
  To: SF Markus Elfring, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, Kalle Valo, brcm80211-dev-list, linux-wireless,
	netdev
  Cc: LKML, kernel-janitors, Julia Lawall

On 11/06/2015 08:58 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 6 Nov 2015 08:48:23 +0100
>
> The release_firmware() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> index 4248f3c..33afb9a 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
> @@ -449,8 +449,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
>
>   	if (raw_nvram)
>   		bcm47xx_nvram_release_contents(data);
> -	if (fw)
> -		release_firmware(fw);
> +	release_firmware(fw);
>   	if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
>   		goto fail;
>
>

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

* [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (39 preceding siblings ...)
  2015-11-06  8:39                                   ` [PATCH] fjes: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
@ 2015-11-14 17:12                                   ` SF Markus Elfring
  2015-11-16 20:11                                     ` David Miller
  2015-11-14 19:05                                   ` [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
                                                     ` (13 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-14 17:12 UTC (permalink / raw)
  To: David S. Miller, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Nov 2015 17:58:00 +0100

The put_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/dsa/dsa.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 1eba07f..045d776 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -671,8 +671,7 @@ static void dsa_of_free_platform_data(struct dsa_platform_data *pd)
 		kfree(pd->chip[i].rtable);
 
 		/* Drop our reference to the MDIO bus device */
-		if (pd->chip[i].host_dev)
-			put_device(pd->chip[i].host_dev);
+		put_device(pd->chip[i].host_dev);
 	}
 	kfree(pd->chip);
 }
-- 
2.6.2


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

* [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (40 preceding siblings ...)
  2015-11-14 17:12                                   ` [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device" SF Markus Elfring
@ 2015-11-14 19:05                                   ` SF Markus Elfring
  2015-11-15  3:32                                     ` Eric Dumazet
  2015-11-14 19:27                                   ` [PATCH] mac802154: Delete an unnecessary check " SF Markus Elfring
                                                     ` (12 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-14 19:05 UTC (permalink / raw)
  To: Alexey Kuznetsov, David S. Miller, Hideaki Yoshfuji,
	James Morris, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Patrick McHardy, netdev, netfilter-devel, coreteam
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Nov 2015 19:55:00 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/ipv6/af_inet6.c                     | 7 ++-----
 net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 44bb66b..4cd9259 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -416,12 +416,9 @@ void inet6_destroy_sock(struct sock *sk)
 	/* Release rx options */
 
 	skb = xchg(&np->pktoptions, NULL);
-	if (skb)
-		kfree_skb(skb);
-
+	kfree_skb(skb);
 	skb = xchg(&np->rxpmtu, NULL);
-	if (skb)
-		kfree_skb(skb);
+	kfree_skb(skb);
 
 	/* Free flowlabels */
 	fl6_free_socklist(sk);
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index d5efeb8..dbc013b 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -172,8 +172,7 @@ static unsigned int nf_hashfn(const struct inet_frag_queue *q)
 
 static void nf_skb_free(struct sk_buff *skb)
 {
-	if (NFCT_FRAG6_CB(skb)->orig)
-		kfree_skb(NFCT_FRAG6_CB(skb)->orig);
+	kfree_skb(NFCT_FRAG6_CB(skb)->orig);
 }
 
 static void nf_ct_frag6_expire(unsigned long data)
-- 
2.6.2

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

* [PATCH] mac802154: Delete an unnecessary check before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (41 preceding siblings ...)
  2015-11-14 19:05                                   ` [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-14 19:27                                   ` SF Markus Elfring
  2015-11-15  0:20                                     ` Marcel Holtmann
  2015-11-14 21:10                                   ` [PATCH] Bluetooth-cmtp: " SF Markus Elfring
                                                     ` (11 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-14 19:27 UTC (permalink / raw)
  To: Alexander Aring, David S. Miller, linux-wpan, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Nov 2015 20:22:41 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/mac802154/rx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index 42e9672..446e130 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -217,8 +217,7 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local,
 		break;
 	}
 
-	if (skb)
-		kfree_skb(skb);
+	kfree_skb(skb);
 }
 
 static void
-- 
2.6.2

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

* [PATCH] Bluetooth-cmtp: Delete an unnecessary check before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (42 preceding siblings ...)
  2015-11-14 19:27                                   ` [PATCH] mac802154: Delete an unnecessary check " SF Markus Elfring
@ 2015-11-14 21:10                                   ` SF Markus Elfring
       [not found]                                     ` <5647A33E.3030103-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-11-14 21:28                                   ` [PATCH] net-hsr: Delete unnecessary checks " SF Markus Elfring
                                                     ` (10 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-14 21:10 UTC (permalink / raw)
  To: David S. Miller, Gustavo Padovan, Johan Hedberg, Marcel Holtmann,
	linux-bluetooth, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Nov 2015 22:00:27 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/bluetooth/cmtp/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index 298ed37..9e59b66 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -178,8 +178,7 @@ static inline int cmtp_recv_frame(struct cmtp_session *session, struct sk_buff *
 			cmtp_add_msgpart(session, id, skb->data + hdrlen, len);
 			break;
 		default:
-			if (session->reassembly[id] != NULL)
-				kfree_skb(session->reassembly[id]);
+			kfree_skb(session->reassembly[id]);
 			session->reassembly[id] = NULL;
 			break;
 		}
-- 
2.6.2

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

* [PATCH] net-hsr: Delete unnecessary checks before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (43 preceding siblings ...)
  2015-11-14 21:10                                   ` [PATCH] Bluetooth-cmtp: " SF Markus Elfring
@ 2015-11-14 21:28                                   ` SF Markus Elfring
  2015-11-24 13:42                                     ` Arvid Brodin
  2015-11-14 21:50                                   ` [PATCH] NFC-nci: " SF Markus Elfring
                                                     ` (9 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-14 21:28 UTC (permalink / raw)
  To: Arvid Brodin, David S. Miller, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Nov 2015 22:23:48 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/hsr/hsr_forward.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
index 7871ed6..55ba943 100644
--- a/net/hsr/hsr_forward.c
+++ b/net/hsr/hsr_forward.c
@@ -355,11 +355,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
 		goto out_drop;
 	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
 	hsr_forward_do(&frame);
-
-	if (frame.skb_hsr != NULL)
-		kfree_skb(frame.skb_hsr);
-	if (frame.skb_std != NULL)
-		kfree_skb(frame.skb_std);
+	kfree_skb(frame.skb_hsr);
+	kfree_skb(frame.skb_std);
 	return;
 
 out_drop:
-- 
2.6.2

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

* [PATCH] NFC-nci: Delete unnecessary checks before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (44 preceding siblings ...)
  2015-11-14 21:28                                   ` [PATCH] net-hsr: Delete unnecessary checks " SF Markus Elfring
@ 2015-11-14 21:50                                   ` SF Markus Elfring
  2015-11-16  9:43                                   ` [PATCH 0/2] mISDN: Deletion of an unnecessary check SF Markus Elfring
                                                     ` (8 subsequent siblings)
  54 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-14 21:50 UTC (permalink / raw)
  To: Aloisio Almeida Jr, David S. Miller, Lauro Ramos Venancio,
	Samuel Ortiz, Vincent Cuissard, linux-wireless, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 14 Nov 2015 22:42:48 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/nfc/nci/uart.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index 21d8875..106ecc1 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -199,11 +199,8 @@ static void nci_uart_tty_close(struct tty_struct *tty)
 	if (!nu)
 		return;
 
-	if (nu->tx_skb)
-		kfree_skb(nu->tx_skb);
-	if (nu->rx_skb)
-		kfree_skb(nu->rx_skb);
-
+	kfree_skb(nu->tx_skb);
+	kfree_skb(nu->rx_skb);
 	skb_queue_purge(&nu->tx_q);
 
 	nu->ops.close(nu);
-- 
2.6.2


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

* Re: [PATCH] mac802154: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-14 19:27                                   ` [PATCH] mac802154: Delete an unnecessary check " SF Markus Elfring
@ 2015-11-15  0:20                                     ` Marcel Holtmann
  0 siblings, 0 replies; 273+ messages in thread
From: Marcel Holtmann @ 2015-11-15  0:20 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Alexander Aring, David S. Miller, linux-wpan, netdev, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> net/mac802154/rx.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* Re: [PATCH] Bluetooth-cmtp: Delete an unnecessary check before the function call "kfree_skb"
       [not found]                                     ` <5647A33E.3030103-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-11-15  0:21                                       ` Marcel Holtmann
  0 siblings, 0 replies; 273+ messages in thread
From: Marcel Holtmann @ 2015-11-15  0:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, Gustavo F. Padovan, Johan Hedberg,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

Hi Markus,

> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> ---
> net/bluetooth/cmtp/core.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

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

* Re: [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
  2015-11-14 19:05                                   ` [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-15  3:32                                     ` Eric Dumazet
  2015-11-15  6:17                                       ` SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Eric Dumazet @ 2015-11-15  3:32 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Alexey Kuznetsov, David S. Miller, Hideaki Yoshfuji,
	James Morris, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Patrick McHardy, netdev, netfilter-devel, coreteam, LKML,
	kernel-janitors, Julia Lawall

On Sat, 2015-11-14 at 20:05 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 14 Nov 2015 19:55:00 +0100
> 
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/ipv6/af_inet6.c                     | 7 ++-----
>  net/ipv6/netfilter/nf_conntrack_reasm.c | 3 +--
>  2 files changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index 44bb66b..4cd9259 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -416,12 +416,9 @@ void inet6_destroy_sock(struct sock *sk)
>  	/* Release rx options */
>  
>  	skb = xchg(&np->pktoptions, NULL);
> -	if (skb)
> -		kfree_skb(skb);
> -
> +	kfree_skb(skb);
>  	skb = xchg(&np->rxpmtu, NULL);
> -	if (skb)
> -		kfree_skb(skb);
> +	kfree_skb(skb);
>  

There is no 'issue' here, or not this one.

In most cases, these pointers are NULL, so the test can be predicted by
the processor.

While if the test is done in kfree_skb(), the branch predictor of the
cpu wont be able to predict things.

By feeding too many NULL pointers to kfree_skb(), we slow down it.

Branch misses and hits were considered important years ago...

But seeing this inet6_destroy_sock() is (ab)using xchg() three times, I
am not sure author cared that much about performance.




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

* Re: net-ipv6: Delete unnecessary checks before the function call "kfree_skb"
  2015-11-15  3:32                                     ` Eric Dumazet
@ 2015-11-15  6:17                                       ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-15  6:17 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Alexey Kuznetsov, David S. Miller, Hideaki Yoshfuji,
	James Morris, Jozsef Kadlecsik, Pablo Neira Ayuso,
	Patrick McHardy, netdev, netfilter-devel, coreteam, LKML,
	kernel-janitors, Julia Lawall

> While if the test is done in kfree_skb(), the branch predictor of the
> cpu wont be able to predict things.
> 
> By feeding too many NULL pointers to kfree_skb(), we slow down it.

Would it make sense to annotate checks before such function calls
as "UNLIKELY"?

Regards,
Markus

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

* [PATCH 0/2] batman-adv: Deletion of some unnecessary checks
       [not found]                                 ` <5317A59D.4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
  2015-02-04 14:22                                   ` [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap" SF Markus Elfring
@ 2015-11-15  8:40                                   ` SF Markus Elfring
  2015-11-15  8:43                                     ` [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
  2015-11-15  8:45                                     ` [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send() SF Markus Elfring
  1 sibling, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-15  8:40 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n-ZwoEplunGu2X36UT3dwllkB+6BGkLq7r,
	netdev-u79uwXL29TY76Z2rM5mHXA
  Cc: Julia Lawall, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, LKML

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Date: Sun, 15 Nov 2015 09:34:12 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete unnecessary checks before the function call "kfree_skb"
  Less checks in batadv_tvlv_unicast_send()

 net/batman-adv/main.c           | 15 +++++----------
 net/batman-adv/network-coding.c |  4 +---
 net/batman-adv/send.c           |  3 +--
 3 files changed, 7 insertions(+), 15 deletions(-)

-- 
2.6.2

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

* [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb"
  2015-11-15  8:40                                   ` [PATCH 0/2] batman-adv: Deletion of some unnecessary checks SF Markus Elfring
@ 2015-11-15  8:43                                     ` SF Markus Elfring
  2015-11-21 21:45                                       ` [B.A.T.M.A.N.] " Marek Lindner
  2015-11-15  8:45                                     ` [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send() SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-15  8:43 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 15 Nov 2015 08:04:43 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/main.c           | 2 +-
 net/batman-adv/network-coding.c | 4 +---
 net/batman-adv/send.c           | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index d7f17c1..9e9b8f6 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -1184,7 +1184,7 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
 		ret = true;
 
 out:
-	if (skb && !ret)
+	if (!ret)
 		kfree_skb(skb);
 	if (orig_node)
 		batadv_orig_node_free_ref(orig_node);
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index f5276be..c98b0ab 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -244,9 +244,7 @@ static void batadv_nc_path_free_ref(struct batadv_nc_path *nc_path)
  */
 static void batadv_nc_packet_free(struct batadv_nc_packet *nc_packet)
 {
-	if (nc_packet->skb)
-		kfree_skb(nc_packet->skb);
-
+	kfree_skb(nc_packet->skb);
 	batadv_nc_path_free_ref(nc_packet->nc_path);
 	kfree(nc_packet);
 }
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index f664324..782fa33 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -407,8 +407,7 @@ void batadv_schedule_bat_ogm(struct batadv_hard_iface *hard_iface)
 
 static void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet)
 {
-	if (forw_packet->skb)
-		kfree_skb(forw_packet->skb);
+	kfree_skb(forw_packet->skb);
 	if (forw_packet->if_incoming)
 		batadv_hardif_free_ref(forw_packet->if_incoming);
 	if (forw_packet->if_outgoing)
-- 
2.6.2


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

* [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send()
  2015-11-15  8:40                                   ` [PATCH 0/2] batman-adv: Deletion of some unnecessary checks SF Markus Elfring
  2015-11-15  8:43                                     ` [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-15  8:45                                     ` SF Markus Elfring
  2015-11-21 21:47                                       ` [B.A.T.M.A.N.] " Marek Lindner
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-15  8:45 UTC (permalink / raw)
  To: Antonio Quartulli, David S. Miller, Marek Lindner,
	Simon Wunderlich, b.a.t.m.a.n, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 15 Nov 2015 09:00:42 +0100

* Let us return directly if a call of the batadv_orig_hash_find() function
  returned a null pointer.

* Omit the initialisation for the variable "skb" at the beginning.

* Replace an assignment by a call of the kfree_skb() function
  and delete the affected variable "ret" then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/main.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 9e9b8f6..4eaa09a 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -1143,15 +1143,14 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
 	struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
 	struct batadv_tvlv_hdr *tvlv_hdr;
 	struct batadv_orig_node *orig_node;
-	struct sk_buff *skb = NULL;
+	struct sk_buff *skb;
 	unsigned char *tvlv_buff;
 	unsigned int tvlv_len;
 	ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
-	bool ret = false;
 
 	orig_node = batadv_orig_hash_find(bat_priv, dst);
 	if (!orig_node)
-		goto out;
+		return;
 
 	tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len;
 
@@ -1180,14 +1179,10 @@ void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, u8 *src,
 	tvlv_buff += sizeof(*tvlv_hdr);
 	memcpy(tvlv_buff, tvlv_value, tvlv_value_len);
 
-	if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
-		ret = true;
-
-out:
-	if (!ret)
+	if (batadv_send_skb_to_orig(skb, orig_node, NULL) == NET_XMIT_DROP)
 		kfree_skb(skb);
-	if (orig_node)
-		batadv_orig_node_free_ref(orig_node);
+out:
+	batadv_orig_node_free_ref(orig_node);
 }
 
 /**
-- 
2.6.2

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

* [PATCH 0/2] mISDN: Deletion of an unnecessary check
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (45 preceding siblings ...)
  2015-11-14 21:50                                   ` [PATCH] NFC-nci: " SF Markus Elfring
@ 2015-11-16  9:43                                   ` SF Markus Elfring
  2015-11-16  9:45                                     ` [PATCH 1/2] mISDN: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
  2015-11-16  9:47                                     ` [PATCH 2/2] mISDN: One function call less in mISDN_sock_sendmsg() after error detection SF Markus Elfring
  2015-11-16 10:22                                   ` [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
                                                     ` (7 subsequent siblings)
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16  9:43 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 10:40:11 +0100

Another update suggestion was taken into account after a patch was applied
from static source code analysis.

Markus Elfring (2):
  Delete an unnecessary check before the function call "kfree_skb"
  One function call less in mISDN_sock_sendmsg() after error detection

 drivers/isdn/mISDN/socket.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

-- 
2.6.2

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

* [PATCH 1/2] mISDN: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-16  9:43                                   ` [PATCH 0/2] mISDN: Deletion of an unnecessary check SF Markus Elfring
@ 2015-11-16  9:45                                     ` SF Markus Elfring
  2015-11-16  9:47                                     ` [PATCH 2/2] mISDN: One function call less in mISDN_sock_sendmsg() after error detection SF Markus Elfring
  1 sibling, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16  9:45 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 10:10:53 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/isdn/mISDN/socket.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index 0d29b5a..edd16ef 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -236,8 +236,7 @@ mISDN_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 	}
 
 done:
-	if (skb)
-		kfree_skb(skb);
+	kfree_skb(skb);
 	release_sock(sk);
 	return err;
 }
-- 
2.6.2

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

* [PATCH 2/2] mISDN: One function call less in mISDN_sock_sendmsg() after error detection
  2015-11-16  9:43                                   ` [PATCH 0/2] mISDN: Deletion of an unnecessary check SF Markus Elfring
  2015-11-16  9:45                                     ` [PATCH 1/2] mISDN: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-16  9:47                                     ` SF Markus Elfring
  1 sibling, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16  9:47 UTC (permalink / raw)
  To: Karsten Keil, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 10:30:29 +0100

The kfree_skb() function was called in one case by the
mISDN_sock_sendmsg() function during error handling even if a call of
the _l2_alloc_skb() function returned a null pointer.

This implementation detail could be improved by the introduction
of another jump label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/isdn/mISDN/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c
index edd16ef..430ac8c 100644
--- a/drivers/isdn/mISDN/socket.c
+++ b/drivers/isdn/mISDN/socket.c
@@ -200,7 +200,7 @@ mISDN_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 
 	skb = _l2_alloc_skb(len, GFP_KERNEL);
 	if (!skb)
-		goto done;
+		goto release_socket;
 
 	if (memcpy_from_msg(skb_put(skb, len), msg, len)) {
 		err = -EFAULT;
@@ -237,6 +237,7 @@ mISDN_sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 
 done:
 	kfree_skb(skb);
+release_socket:
 	release_sock(sk);
 	return err;
 }
-- 
2.6.2

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

* [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (46 preceding siblings ...)
  2015-11-16  9:43                                   ` [PATCH 0/2] mISDN: Deletion of an unnecessary check SF Markus Elfring
@ 2015-11-16 10:22                                   ` SF Markus Elfring
  2016-07-19 20:11                                     ` SF Markus Elfring
  2015-11-16 11:28                                   ` [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
                                                     ` (6 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16 10:22 UTC (permalink / raw)
  To: Inaky Perez-Gonzalez, linux-wimax, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 11:17:55 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wimax/i2400m/control.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
index 4c41790..4de22b7 100644
--- a/drivers/net/wimax/i2400m/control.c
+++ b/drivers/net/wimax/i2400m/control.c
@@ -644,7 +644,7 @@ void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)
 
 	spin_lock_irqsave(&i2400m->rx_lock, flags);
 	ack_skb = i2400m->ack_skb;
-	if (ack_skb && !IS_ERR(ack_skb))
+	if (!IS_ERR(ack_skb))
 		kfree_skb(ack_skb);
 	i2400m->ack_skb = ERR_PTR(code);
 	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
-- 
2.6.2

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

* [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (47 preceding siblings ...)
  2015-11-16 10:22                                   ` [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-16 11:28                                   ` SF Markus Elfring
  2015-11-25 12:19                                     ` Krzysztof Hałasa
  2015-11-16 11:52                                   ` [PATCH] cxgb3: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
                                                     ` (5 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16 11:28 UTC (permalink / raw)
  To: netdev, Krzysztof Halasa; +Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 12:23:23 +0100

The dma_pool_destroy() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/xscale/ixp4xx_eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 5138407..6705951 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1192,7 +1192,7 @@ static void destroy_queues(struct port *port)
 		port->desc_tab = NULL;
 	}
 
-	if (!ports_open && dma_pool) {
+	if (!ports_open) {
 		dma_pool_destroy(dma_pool);
 		dma_pool = NULL;
 	}
-- 
2.6.2


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

* [PATCH] cxgb3: Delete unnecessary checks before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (48 preceding siblings ...)
  2015-11-16 11:28                                   ` [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
@ 2015-11-16 11:52                                   ` SF Markus Elfring
  2015-11-16 12:18                                   ` [PATCH] rtlwifi: " SF Markus Elfring
                                                     ` (4 subsequent siblings)
  54 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16 11:52 UTC (permalink / raw)
  To: netdev, Santosh Raspatur; +Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 12:46:41 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c    | 3 +--
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 8f7aa53a..89f193b 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -3401,8 +3401,7 @@ static void remove_one(struct pci_dev *pdev)
 				free_netdev(adapter->port[i]);
 
 		iounmap(adapter->regs);
-		if (adapter->nofail_skb)
-			kfree_skb(adapter->nofail_skb);
+		kfree_skb(adapter->nofail_skb);
 		kfree(adapter);
 		pci_release_regions(pdev);
 		pci_disable_device(pdev);
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c
index 76684dc..9a77339 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c
@@ -1323,8 +1323,7 @@ void cxgb3_offload_deactivate(struct adapter *adapter)
 	rcu_read_unlock();
 	RCU_INIT_POINTER(tdev->l2opt, NULL);
 	call_rcu(&d->rcu_head, clean_l2_data);
-	if (t->nofail_skb)
-		kfree_skb(t->nofail_skb);
+	kfree_skb(t->nofail_skb);
 	kfree(t);
 }
 
-- 
2.6.2

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

* [PATCH] rtlwifi: Delete unnecessary checks before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (49 preceding siblings ...)
  2015-11-16 11:52                                   ` [PATCH] cxgb3: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-16 12:18                                   ` SF Markus Elfring
  2015-11-26 13:01                                     ` rtlwifi: Delete unnecessary checks before the function call"kfree_skb" Kalle Valo
  2015-11-16 12:36                                   ` [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
                                                     ` (3 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16 12:18 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 13:12:25 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/realtek/rtlwifi/core.c                 | 3 +--
 drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c | 4 +---
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c
index c925a4d..4ae421e 100644
--- a/drivers/net/wireless/realtek/rtlwifi/core.c
+++ b/drivers/net/wireless/realtek/rtlwifi/core.c
@@ -1833,8 +1833,7 @@ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb)
 
 	spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
 	pskb = __skb_dequeue(&ring->queue);
-	if (pskb)
-		kfree_skb(pskb);
+	kfree_skb(pskb);
 
 	/*this is wrong, fill_tx_cmddesc needs update*/
 	pdesc = &ring->desc[0];
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c
index a2f5e89..6e51862 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c
@@ -318,9 +318,7 @@ bool rtl8723_cmd_send_packet(struct ieee80211_hw *hw,
 	ring = &rtlpci->tx_ring[BEACON_QUEUE];
 
 	pskb = __skb_dequeue(&ring->queue);
-	if (pskb)
-		kfree_skb(pskb);
-
+	kfree_skb(pskb);
 	spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags);
 
 	pdesc = &ring->desc[0];
-- 
2.6.2

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

* [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (50 preceding siblings ...)
  2015-11-16 12:18                                   ` [PATCH] rtlwifi: " SF Markus Elfring
@ 2015-11-16 12:36                                   ` SF Markus Elfring
  2015-11-25 12:19                                     ` Krzysztof Hałasa
  2015-11-16 12:57                                   ` [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
                                                     ` (2 subsequent siblings)
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16 12:36 UTC (permalink / raw)
  To: netdev, Krzysztof Halasa; +Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 13:30:37 +0100

The dma_pool_destroy() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wan/ixp4xx_hss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index e7bbdb7..0d2593a 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -1037,7 +1037,7 @@ static void destroy_hdlc_queues(struct port *port)
 		port->desc_tab = NULL;
 	}
 
-	if (!ports_open && dma_pool) {
+	if (!ports_open) {
 		dma_pool_destroy(dma_pool);
 		dma_pool = NULL;
 	}
-- 
2.6.2

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

* [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (51 preceding siblings ...)
  2015-11-16 12:36                                   ` [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
@ 2015-11-16 12:57                                   ` SF Markus Elfring
  2015-11-16 13:46                                     ` Stefan Schmidt
  2015-11-17 16:17                                   ` Stefan Schmidt
  2015-11-17 16:43                                   ` [PATCH] net-scm: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
  54 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-16 12:57 UTC (permalink / raw)
  To: Alexander Aring, Stefan Schmidt, linux-wpan, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 13:50:23 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ieee802154/atusb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 199a94a..b1cd865 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
 		urb = usb_get_from_anchor(&atusb->idle_urbs);
 		if (!urb)
 			break;
-		if (urb->context)
-			kfree_skb(urb->context);
+		kfree_skb(urb->context);
 		usb_free_urb(urb);
 	}
 }
-- 
2.6.2

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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-16 12:57                                   ` [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-16 13:46                                     ` Stefan Schmidt
  2015-11-17 14:01                                       ` Marcel Holtmann
  0 siblings, 1 reply; 273+ messages in thread
From: Stefan Schmidt @ 2015-11-16 13:46 UTC (permalink / raw)
  To: SF Markus Elfring, Alexander Aring, linux-wpan, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

Hello.

On 16/11/15 13:57, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 13:50:23 +0100
>
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/net/ieee802154/atusb.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
> index 199a94a..b1cd865 100644
> --- a/drivers/net/ieee802154/atusb.c
> +++ b/drivers/net/ieee802154/atusb.c
> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>   		urb = usb_get_from_anchor(&atusb->idle_urbs);
>   		if (!urb)
>   			break;
> -		if (urb->context)
> -			kfree_skb(urb->context);
> +		kfree_skb(urb->context);
>   		usb_free_urb(urb);
>   	}
>   }

Acked-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

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

* Re: [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device"
  2015-11-14 17:12                                   ` [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device" SF Markus Elfring
@ 2015-11-16 20:11                                     ` David Miller
  0 siblings, 0 replies; 273+ messages in thread
From: David Miller @ 2015-11-16 20:11 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall


I'm starting to grow quite weary of these "unnecessary check" changes.

Sometimes it is better to have them, either because the path is a hot
path or some atomic sequence is involved.

But there is never harm in them being there.

All of this is a matter of taste, of course.  But one thing I know for
sure, it is undisputable that there are much more important things to
work on than this kind of stuff...

So I'm not applying these changes any more and directing my time and
effort to reviewing and applying patches that fix bugs, really
restructure the code in useful ways that increase maintainability over
the long time, and add interesting new features.

These patches do none of the above.

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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-16 13:46                                     ` Stefan Schmidt
@ 2015-11-17 14:01                                       ` Marcel Holtmann
  2015-11-17 16:19                                         ` Stefan Schmidt
  0 siblings, 1 reply; 273+ messages in thread
From: Marcel Holtmann @ 2015-11-17 14:01 UTC (permalink / raw)
  To: Stefan Schmidt
  Cc: SF Markus Elfring, Alexander Aring, linux-wpan,
	Network Development, LKML, kernel-janitors, Julia Lawall

Hi Stefan,

>> The kfree_skb() function tests whether its argument is NULL and then
>> returns immediately. Thus the test around the call is not needed.
>> 
>> This issue was detected by using the Coccinelle software.
>> 
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/net/ieee802154/atusb.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
>> index 199a94a..b1cd865 100644
>> --- a/drivers/net/ieee802154/atusb.c
>> +++ b/drivers/net/ieee802154/atusb.c
>> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>>  		urb = usb_get_from_anchor(&atusb->idle_urbs);
>>  		if (!urb)
>>  			break;
>> -		if (urb->context)
>> -			kfree_skb(urb->context);
>> +		kfree_skb(urb->context);
>>  		usb_free_urb(urb);
>>  	}
>>  }
> 
> Acked-by: Stefan Schmidt <stefan@osg.samsung.com>

for some reason I am missing the original patch, can someone resend it please.

Regards

Marcel


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

* [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (52 preceding siblings ...)
  2015-11-16 12:57                                   ` [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-17 16:17                                   ` Stefan Schmidt
  2015-11-17 16:18                                     ` Stefan Schmidt
  2015-11-17 16:43                                   ` [PATCH] net-scm: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
  54 siblings, 1 reply; 273+ messages in thread
From: Stefan Schmidt @ 2015-11-17 16:17 UTC (permalink / raw)
  To: Alexander Aring, Stefan Schmidt, linux-wpan, netdev, Marcel Holtmann
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 16 Nov 2015 13:50:23 +0100

The kfree_skb() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
  drivers/net/ieee802154/atusb.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
index 199a94a..b1cd865 100644
--- a/drivers/net/ieee802154/atusb.c
+++ b/drivers/net/ieee802154/atusb.c
@@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
  		urb = usb_get_from_anchor(&atusb->idle_urbs);
  		if (!urb)
  			break;
-		if (urb->context)
-			kfree_skb(urb->context);
+		kfree_skb(urb->context);
  		usb_free_urb(urb);
  	}
  }
-- 
2.6.2

--

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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-17 16:17                                   ` Stefan Schmidt
@ 2015-11-17 16:18                                     ` Stefan Schmidt
  2015-12-10 10:14                                       ` Stefan Schmidt
  0 siblings, 1 reply; 273+ messages in thread
From: Stefan Schmidt @ 2015-11-17 16:18 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan, netdev, Marcel Holtmann
  Cc: LKML, kernel-janitors, Julia Lawall

Hello.

On 17/11/15 17:17, Stefan Schmidt wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 13:50:23 +0100
>
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ieee802154/atusb.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ieee802154/atusb.c 
> b/drivers/net/ieee802154/atusb.c
> index 199a94a..b1cd865 100644
> --- a/drivers/net/ieee802154/atusb.c
> +++ b/drivers/net/ieee802154/atusb.c
> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>          urb = usb_get_from_anchor(&atusb->idle_urbs);
>          if (!urb)
>              break;
> -        if (urb->context)
> -            kfree_skb(urb->context);
> +        kfree_skb(urb->context);
>          usb_free_urb(urb);
>      }
>  }

Acked-by: Stefan Schmidt <stefan@osg.samsung.com>

regards
Stefan Schmidt

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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-17 14:01                                       ` Marcel Holtmann
@ 2015-11-17 16:19                                         ` Stefan Schmidt
  0 siblings, 0 replies; 273+ messages in thread
From: Stefan Schmidt @ 2015-11-17 16:19 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: SF Markus Elfring, Alexander Aring, linux-wpan,
	Network Development, LKML, kernel-janitors, Julia Lawall

Hello.

On 17/11/15 15:01, Marcel Holtmann wrote:
> Hi Stefan,
>
>>> The kfree_skb() function tests whether its argument is NULL and then
>>> returns immediately. Thus the test around the call is not needed.
>>>
>>> This issue was detected by using the Coccinelle software.
>>>
>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>> ---
>>>   drivers/net/ieee802154/atusb.c | 3 +--
>>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
>>> index 199a94a..b1cd865 100644
>>> --- a/drivers/net/ieee802154/atusb.c
>>> +++ b/drivers/net/ieee802154/atusb.c
>>> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>>>   		urb = usb_get_from_anchor(&atusb->idle_urbs);
>>>   		if (!urb)
>>>   			break;
>>> -		if (urb->context)
>>> -			kfree_skb(urb->context);
>>> +		kfree_skb(urb->context);
>>>   		usb_free_urb(urb);
>>>   	}
>>>   }
>> Acked-by: Stefan Schmidt <stefan@osg.samsung.com>
> for some reason I am missing the original patch, can someone resend it please.
>

Done. Resend the original message from my address but with the From line 
intact inside the patch. Please check if it really lists Markus as 
author when applying. Acked-by also resend as reply to the resend patch.

regards
Stefan Schmidt

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

* [PATCH] net-scm: Delete an unnecessary check before the function call "kfree"
       [not found]                                 ` <5317A59D.4@users.sourceforge.net>
                                                     ` (53 preceding siblings ...)
  2015-11-17 16:17                                   ` Stefan Schmidt
@ 2015-11-17 16:43                                   ` SF Markus Elfring
  2015-11-17 17:10                                     ` David Miller
  2015-11-17 17:13                                     ` Daniel Borkmann
  54 siblings, 2 replies; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-17 16:43 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 17 Nov 2015 17:37:22 +0100

The kfree() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/core/scm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/scm.c b/net/core/scm.c
index 3b6899b..4f64173 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -193,7 +193,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
 		}
 	}
 
-	if (p->fp && !p->fp->count)
+	if (likely(!p->fp->count))
 	{
 		kfree(p->fp);
 		p->fp = NULL;
-- 
2.6.2

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

* Re: [PATCH] net-scm: Delete an unnecessary check before the function call "kfree"
  2015-11-17 16:43                                   ` [PATCH] net-scm: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
@ 2015-11-17 17:10                                     ` David Miller
  2015-11-17 17:13                                     ` Daniel Borkmann
  1 sibling, 0 replies; 273+ messages in thread
From: David Miller @ 2015-11-17 17:10 UTC (permalink / raw)
  To: elfring; +Cc: netdev, linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 17 Nov 2015 17:43:35 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 17 Nov 2015 17:37:22 +0100
> 
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

STOP submitting this crap, NOW!

I told you I won't review nor apply these patches any more.

And ever worse, this one is BUGGY.

We're testing p->fp so we know if we can safely dereference
it or not.

You're adding an OOPS to the kernel.

This is why these mindless mechanical transformations are not
only often a waste of time, they are dangerous as well.

I am silently rejecting from patchwork, immediately, any and all
patches you submit of this nature.

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

* Re: [PATCH] net-scm: Delete an unnecessary check before the function call "kfree"
  2015-11-17 16:43                                   ` [PATCH] net-scm: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
  2015-11-17 17:10                                     ` David Miller
@ 2015-11-17 17:13                                     ` Daniel Borkmann
  2015-11-17 18:05                                       ` SF Markus Elfring
  1 sibling, 1 reply; 273+ messages in thread
From: Daniel Borkmann @ 2015-11-17 17:13 UTC (permalink / raw)
  To: SF Markus Elfring, netdev, David S. Miller
  Cc: linux-kernel, kernel-janitors, Julia Lawall, eric.dumazet

On 11/17/2015 05:43 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 17 Nov 2015 17:37:22 +0100
>
> The kfree() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   net/core/scm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/core/scm.c b/net/core/scm.c
> index 3b6899b..4f64173 100644
> --- a/net/core/scm.c
> +++ b/net/core/scm.c
> @@ -193,7 +193,7 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
>   		}
>   	}
>
> -	if (p->fp && !p->fp->count)
> +	if (likely(!p->fp->count))
>   	{
>   		kfree(p->fp);
>   		p->fp = NULL;
>

Really, I don't like your blind, silly removals everywhere throughout
the kernel tree for these tests. Eric already mentioned that in some
situations where it's critical, it actually slows down the code, i.e.
you'll have an extra function call to get there and inside kfree() /
kfree_skb() / etc, the test is actually marked as unlikely().

Anyway, I think this one in particular could throw a NULL pointer deref.
You even say in your commit message "kfree() function tests whether its
argument [p->fp] is NULL" and yet if that is the case then, you already
deref'ed on the p->fp->count test ???

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

* Re: net-scm: Delete an unnecessary check before the function call "kfree"
  2015-11-17 17:13                                     ` Daniel Borkmann
@ 2015-11-17 18:05                                       ` SF Markus Elfring
  2015-11-17 18:37                                         ` Daniel Borkmann
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-17 18:05 UTC (permalink / raw)
  To: Daniel Borkmann, netdev, David S. Miller
  Cc: linux-kernel, kernel-janitors, Julia Lawall, eric.dumazet

> Eric already mentioned that in some situations where it's critical,
> it actually slows down the code, i.e. you'll have an extra
> function call to get there and inside kfree() / kfree_skb() / etc,
> the test is actually marked as unlikely().

How do you think about to add similar annotations to any more
source code places?

Regards,
Markus

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

* Re: net-scm: Delete an unnecessary check before the function call "kfree"
  2015-11-17 18:05                                       ` SF Markus Elfring
@ 2015-11-17 18:37                                         ` Daniel Borkmann
  2015-11-18  7:45                                           ` net-scm: Macro for special pattern? SF Markus Elfring
  0 siblings, 1 reply; 273+ messages in thread
From: Daniel Borkmann @ 2015-11-17 18:37 UTC (permalink / raw)
  To: SF Markus Elfring, netdev, David S. Miller
  Cc: linux-kernel, kernel-janitors, Julia Lawall, eric.dumazet

On 11/17/2015 07:05 PM, SF Markus Elfring wrote:
>> Eric already mentioned that in some situations where it's critical,
>> it actually slows down the code, i.e. you'll have an extra
>> function call to get there and inside kfree() / kfree_skb() / etc,
>> the test is actually marked as unlikely().
>
> How do you think about to add similar annotations to any more
> source code places?

You mean this likely() annotation of yours? It doesn't make any sense
to me to place it there, and since you've spend the second thinking
about it when adding it to the diff, you should have already realized
that your code was buggy ...

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

* Re: net-scm: Macro for special pattern?
  2015-11-17 18:37                                         ` Daniel Borkmann
@ 2015-11-18  7:45                                           ` SF Markus Elfring
  2015-11-18 12:43                                             ` Eric Dumazet
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-18  7:45 UTC (permalink / raw)
  To: Daniel Borkmann, netdev, David S. Miller
  Cc: linux-kernel, kernel-janitors, Julia Lawall, Eric Dumazet

> You mean this likely() annotation of yours?

How do you think about to express the software design pattern
which is applied at the mentioned source code place by a dedicated
preprocessor macro?

Regards,
Markus

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

* Re: net-scm: Macro for special pattern?
  2015-11-18  7:45                                           ` net-scm: Macro for special pattern? SF Markus Elfring
@ 2015-11-18 12:43                                             ` Eric Dumazet
  0 siblings, 0 replies; 273+ messages in thread
From: Eric Dumazet @ 2015-11-18 12:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Daniel Borkmann, netdev, David S. Miller, linux-kernel,
	kernel-janitors, Julia Lawall

On Wed, 2015-11-18 at 08:45 +0100, SF Markus Elfring wrote:
> > You mean this likely() annotation of yours?
> 
> How do you think about to express the software design pattern
> which is applied at the mentioned source code place by a dedicated
> preprocessor macro?

likely()/unlikely() are not always applicable.

In the Ipv6 case I mentioned to you, it all depends if an application
for some reason absolutely wants the sockets to store the extra skb

There are seldom used socket options. _if_/_when_ they are used, a
likely()/unlikely() would give the wrong signal.

likely() should only be used in contexts we know better than branch
predictor/compiler.

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

* Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
  2015-11-03 20:56                                     ` [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection SF Markus Elfring
@ 2015-11-20  8:47                                       ` Antonio Quartulli
       [not found]                                       ` <564EDE1D.7070809@meshcoding.com>
  1 sibling, 0 replies; 273+ messages in thread
From: Antonio Quartulli @ 2015-11-20  8:47 UTC (permalink / raw)
  To: elfring
  Cc: The list for a Better Approach To Mobile Ad-hoc Networking,
	David S. Miller, Marek Lindner, Simon Wunderlich, netdev,
	Julia Lawall, kernel-janitors, LKML

[-- Attachment #1: Type: text/plain, Size: 2269 bytes --]

On 04/11/15 04:56, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 3 Nov 2015 21:10:51 +0100
> 
> The variables "tt_local_entry" and "tt_global_entry" were eventually checked
> again despite of a corresponding null pointer test before.
> Let us avoid this double check by reordering a function call sequence
> and the better selection of jump targets.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/batman-adv/translation-table.c | 21 +++++++++------------
>  1 file changed, 9 insertions(+), 12 deletions(-)
> 
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 965a004..3ac32d9 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
> @@ -3323,27 +3323,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
>  		return false;
>  
>  	if (!atomic_read(&vlan->ap_isolation))
> -		goto out;
> +		goto vlan_free;
>  
>  	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
>  	if (!tt_local_entry)
> -		goto out;
> +		goto vlan_free;
>  
>  	tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
>  	if (!tt_global_entry)
> -		goto out;
> +		goto local_entry_free;
>  
> -	if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
> -		goto out;
> -
> -	ret = true;
> +	if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
> +		ret = true;
>  
> -out:
> +	batadv_tt_global_entry_free_ref(tt_global_entry);
> +local_entry_free:
> +	batadv_tt_local_entry_free_ref(tt_local_entry);
> +vlan_free:
>  	batadv_softif_vlan_free_ref(vlan);
> -	if (tt_global_entry)
> -		batadv_tt_global_entry_free_ref(tt_global_entry);
> -	if (tt_local_entry)
> -		batadv_tt_local_entry_free_ref(tt_local_entry);
>  	return ret;

Markus,
if you really want to make this codestyle change, I'd suggest you to go
through the whole batman-adv code and apply the same change where
needed. It does not make sense to change the codestyle in one spot only.

On top of that, by going through the batman-adv code you might agree
that the current style is actually not a bad idea.


Cheers,

-- 
Antonio Quartulli


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
       [not found]                                         ` <564EDE1D.7070809-x4xJYDvStAgysxA8WJXlww@public.gmane.org>
@ 2015-11-20 10:56                                           ` SF Markus Elfring
       [not found]                                             ` <1655341.WCvHHx7pqD@bentobox>
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-11-20 10:56 UTC (permalink / raw)
  To: Antonio Quartulli
  Cc: Marek Lindner, netdev-u79uwXL29TY76Z2rM5mHXA,
	The list for a Better Approach To Mobile Ad-hoc Networking,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, LKML, Julia Lawall,
	David S. Miller

>> -out:
>> +	batadv_tt_global_entry_free_ref(tt_global_entry);
>> +local_entry_free:
>> +	batadv_tt_local_entry_free_ref(tt_local_entry);
>> +vlan_free:
>>  	batadv_softif_vlan_free_ref(vlan);
>> -	if (tt_global_entry)
>> -		batadv_tt_global_entry_free_ref(tt_global_entry);
>> -	if (tt_local_entry)
>> -		batadv_tt_local_entry_free_ref(tt_local_entry);
>>  	return ret;

> if you really want to make this codestyle change, I'd suggest you to go
> through the whole batman-adv code and apply the same change where needed.

Thanks for your interest in similar source code changes.

I would prefer general acceptance for this specific update suggestion
before I might invest further software development efforts for the
affected network module.


> It does not make sense to change the codestyle in one spot only.

I agree in the way that I would be nice if more places can still be improved.


> On top of that, by going through the batman-adv code you might agree
> that the current style is actually not a bad idea.

I got the impression that the current Linux coding style convention
disagrees around the affected jump label selection to some degree,
doesn't it?

Regards,
Markus

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

* Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb"
  2015-11-15  8:43                                     ` [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
@ 2015-11-21 21:45                                       ` Marek Lindner
  0 siblings, 0 replies; 273+ messages in thread
From: Marek Lindner @ 2015-11-21 21:45 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: SF Markus Elfring, Antonio Quartulli, David S. Miller,
	Simon Wunderlich, netdev, Julia Lawall, kernel-janitors, LKML

[-- Attachment #1: Type: text/plain, Size: 663 bytes --]

On Sunday, November 15, 2015 09:43:26 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 15 Nov 2015 08:04:43 +0100
> 
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/batman-adv/main.c           | 2 +-
>  net/batman-adv/network-coding.c | 4 +---
>  net/batman-adv/send.c           | 3 +--
>  3 files changed, 3 insertions(+), 6 deletions(-)

Applied in revision 77d84a6.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send()
  2015-11-15  8:45                                     ` [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send() SF Markus Elfring
@ 2015-11-21 21:47                                       ` Marek Lindner
  0 siblings, 0 replies; 273+ messages in thread
From: Marek Lindner @ 2015-11-21 21:47 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: SF Markus Elfring, Antonio Quartulli, David S. Miller,
	Simon Wunderlich, netdev, Julia Lawall, kernel-janitors, LKML

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

On Sunday, November 15, 2015 09:45:51 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 15 Nov 2015 09:00:42 +0100
> 
> * Let us return directly if a call of the batadv_orig_hash_find() function
>   returned a null pointer.
> 
> * Omit the initialisation for the variable "skb" at the beginning.
> 
> * Replace an assignment by a call of the kfree_skb() function
>   and delete the affected variable "ret" then.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/batman-adv/main.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)

Applied in revision 5a878b8.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref"
  2015-11-03 20:52                                     ` [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref" SF Markus Elfring
@ 2015-11-21 21:48                                       ` Marek Lindner
  0 siblings, 0 replies; 273+ messages in thread
From: Marek Lindner @ 2015-11-21 21:48 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: SF Markus Elfring, Antonio Quartulli, David S. Miller,
	Simon Wunderlich, netdev, Julia Lawall, kernel-janitors, LKML

[-- Attachment #1: Type: text/plain, Size: 597 bytes --]

On Tuesday, November 03, 2015 21:52:58 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 3 Nov 2015 19:20:34 +0100
> 
> The batadv_softif_vlan_free_ref() function tests whether its argument is
> NULL and then returns immediately. Thus the test around the call is not
> needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/batman-adv/translation-table.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied in revision bbcbe0f.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Split a condition check
  2015-11-03 20:54                                     ` [PATCH 2/3] batman-adv: Split a condition check SF Markus Elfring
@ 2015-11-21 21:51                                       ` Marek Lindner
  0 siblings, 0 replies; 273+ messages in thread
From: Marek Lindner @ 2015-11-21 21:51 UTC (permalink / raw)
  To: b.a.t.m.a.n
  Cc: SF Markus Elfring, Antonio Quartulli, David S. Miller,
	Simon Wunderlich, netdev, Julia Lawall, kernel-janitors, LKML

[-- Attachment #1: Type: text/plain, Size: 584 bytes --]

On Tuesday, November 03, 2015 21:54:35 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 3 Nov 2015 20:41:02 +0100
> 
> Let us split a check for a condition at the beginning of the
> batadv_is_ap_isolated() function so that a direct return can be performed
> in this function if the variable "vlan" contained a null pointer.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  net/batman-adv/translation-table.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Applied in revision b1199c6.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

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

* Re: [PATCH] net-hsr: Delete unnecessary checks before the function call "kfree_skb"
  2015-11-14 21:28                                   ` [PATCH] net-hsr: Delete unnecessary checks " SF Markus Elfring
@ 2015-11-24 13:42                                     ` Arvid Brodin
  0 siblings, 0 replies; 273+ messages in thread
From: Arvid Brodin @ 2015-11-24 13:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David S. Miller, netdev, LKML, kernel-janitors, Julia Lawall,
	Arvid Brodin

On 2015-11-14 22:28, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 14 Nov 2015 22:23:48 +0100
> 
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the calls is not needed.
> 

> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 7871ed6..55ba943 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c
> @@ -355,11 +355,8 @@ void hsr_forward_skb(struct sk_buff *skb, struct hsr_port *port)
>  		goto out_drop;
>  	hsr_register_frame_in(frame.node_src, port, frame.sequence_nr);
>  	hsr_forward_do(&frame);
> -
> -	if (frame.skb_hsr != NULL)
> -		kfree_skb(frame.skb_hsr);
> -	if (frame.skb_std != NULL)
> -		kfree_skb(frame.skb_std);
> +	kfree_skb(frame.skb_hsr);
> +	kfree_skb(frame.skb_std);

Thanks for doing checks on the HSR code, and I apologise for the late reply! Not sure if this has
already been applied, but:

You're right of course that these checks are not strictly necessary. However, it is likely that at 
least one of these (.skb_hsr or .skb_std) will be NULL here, so it could be considered nice form to 
check for this and not just trust kfree_skb() to do this. I'm not sure what's considered more 
correct in the kernel, so I will just say that I'm agnostic about this and let others decide.

Again, thanks!

-- 
Arvid Brodin
ALTEN Sweden
www.alten.com | www.alten.se

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

* Re: [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy"
  2015-11-16 11:28                                   ` [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
@ 2015-11-25 12:19                                     ` Krzysztof Hałasa
  0 siblings, 0 replies; 273+ messages in thread
From: Krzysztof Hałasa @ 2015-11-25 12:19 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: netdev, linux-kernel, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> The dma_pool_destroy() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.

> --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
> +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
> @@ -1192,7 +1192,7 @@ static void destroy_queues(struct port *port)
>  		port->desc_tab = NULL;
>  	}
>  
> -	if (!ports_open && dma_pool) {
> +	if (!ports_open) {
>  		dma_pool_destroy(dma_pool);
>  		dma_pool = NULL;
>  	}

Acked-by: Krzysztof Halasa <khalasa@piap.pl>
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

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

* Re: [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy"
  2015-11-16 12:36                                   ` [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
@ 2015-11-25 12:19                                     ` Krzysztof Hałasa
  0 siblings, 0 replies; 273+ messages in thread
From: Krzysztof Hałasa @ 2015-11-25 12:19 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: netdev, linux-kernel, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> The dma_pool_destroy() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.

> --- a/drivers/net/wan/ixp4xx_hss.c
> +++ b/drivers/net/wan/ixp4xx_hss.c
> @@ -1037,7 +1037,7 @@ static void destroy_hdlc_queues(struct port *port)
>  		port->desc_tab = NULL;
>  	}
>  
> -	if (!ports_open && dma_pool) {
> +	if (!ports_open) {
>  		dma_pool_destroy(dma_pool);
>  		dma_pool = NULL;
>  	}

Acked-by: Krzysztof Halasa <khalasa@piap.pl>
-- 
Krzysztof Halasa

Industrial Research Institute for Automation and Measurements PIAP
Al. Jerozolimskie 202, 02-486 Warsaw, Poland

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

* Re: brcm80211: Delete an unnecessary check before the function call"release_firmware"
       [not found]                                         ` <563C5DA2.3000005-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
@ 2015-11-26 12:04                                           ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-11-26 12:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Arend van Spriel, Brett Rudley, Franky (Zhenhui) Lin,
	Hante Meuleman, brcm80211-dev-list-dY08KVG/lbpWk0Htik3J/w,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, LKML,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall


> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Date: Fri, 6 Nov 2015 08:48:23 +0100
> 
> The release_firmware() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> Acked-by: Arend van Spriel <arend-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: rtlwifi: Delete unnecessary checks before the function call"kfree_skb"
  2015-11-16 12:18                                   ` [PATCH] rtlwifi: " SF Markus Elfring
@ 2015-11-26 13:01                                     ` Kalle Valo
  0 siblings, 0 replies; 273+ messages in thread
From: Kalle Valo @ 2015-11-26 13:01 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, linux-kernel, kernel-janitors, Julia Lawall


> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 13:12:25 +0100
> 
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the calls is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-17 16:18                                     ` Stefan Schmidt
@ 2015-12-10 10:14                                       ` Stefan Schmidt
  2015-12-10 18:16                                         ` Marcel Holtmann
  0 siblings, 1 reply; 273+ messages in thread
From: Stefan Schmidt @ 2015-12-10 10:14 UTC (permalink / raw)
  To: Alexander Aring, linux-wpan, netdev, Marcel Holtmann
  Cc: LKML, kernel-janitors, Julia Lawall

Marcel,

On 17/11/15 17:18, Stefan Schmidt wrote:
> Hello.
>
> On 17/11/15 17:17, Stefan Schmidt wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Mon, 16 Nov 2015 13:50:23 +0100
>>
>> The kfree_skb() function tests whether its argument is NULL and then
>> returns immediately. Thus the test around the call is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/net/ieee802154/atusb.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ieee802154/atusb.c 
>> b/drivers/net/ieee802154/atusb.c
>> index 199a94a..b1cd865 100644
>> --- a/drivers/net/ieee802154/atusb.c
>> +++ b/drivers/net/ieee802154/atusb.c
>> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>>          urb = usb_get_from_anchor(&atusb->idle_urbs);
>>          if (!urb)
>>              break;
>> -        if (urb->context)
>> -            kfree_skb(urb->context);
>> +        kfree_skb(urb->context);
>>          usb_free_urb(urb);
>>      }
>>  }
>
> Acked-by: Stefan Schmidt <stefan@osg.samsung.com>


You got the original patch and my ACK on this one or would you prefer me 
to resend it again?

regards
Stefan Schmidt

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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-12-10 10:14                                       ` Stefan Schmidt
@ 2015-12-10 18:16                                         ` Marcel Holtmann
  2015-12-10 22:45                                           ` Stefan Schmidt
  2015-12-11 13:07                                           ` SF Markus Elfring
  0 siblings, 2 replies; 273+ messages in thread
From: Marcel Holtmann @ 2015-12-10 18:16 UTC (permalink / raw)
  To: Stefan Schmidt
  Cc: Alexander Aring, linux-wpan, Network Development, LKML,
	kernel-janitors, Julia Lawall

Hi Stefan,

>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>> Date: Mon, 16 Nov 2015 13:50:23 +0100
>>> 
>>> The kfree_skb() function tests whether its argument is NULL and then
>>> returns immediately. Thus the test around the call is not needed.
>>> 
>>> This issue was detected by using the Coccinelle software.
>>> 
>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>> ---
>>> drivers/net/ieee802154/atusb.c | 3 +--
>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>> 
>>> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
>>> index 199a94a..b1cd865 100644
>>> --- a/drivers/net/ieee802154/atusb.c
>>> +++ b/drivers/net/ieee802154/atusb.c
>>> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>>>         urb = usb_get_from_anchor(&atusb->idle_urbs);
>>>         if (!urb)
>>>             break;
>>> -        if (urb->context)
>>> -            kfree_skb(urb->context);
>>> +        kfree_skb(urb->context);
>>>         usb_free_urb(urb);
>>>     }
>>> }
>> 
>> Acked-by: Stefan Schmidt <stefan@osg.samsung.com>
> 
> 
> You got the original patch and my ACK on this one or would you prefer me to resend it again?

this slipped through, but now it does no longer apply.

Applying: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
error: patch failed: drivers/net/ieee802154/atusb.c:310
error: drivers/net/ieee802154/atusb.c: patch does not apply
Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"

Regards

Marcel


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

* Re: [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-12-10 18:16                                         ` Marcel Holtmann
@ 2015-12-10 22:45                                           ` Stefan Schmidt
  2015-12-11 13:07                                           ` SF Markus Elfring
  1 sibling, 0 replies; 273+ messages in thread
From: Stefan Schmidt @ 2015-12-10 22:45 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Alexander Aring, linux-wpan, Network Development, LKML,
	kernel-janitors, Julia Lawall

Hello.

On 10/12/15 19:16, Marcel Holtmann wrote:
> Hi Stefan,
>
>>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>>> Date: Mon, 16 Nov 2015 13:50:23 +0100
>>>>
>>>> The kfree_skb() function tests whether its argument is NULL and then
>>>> returns immediately. Thus the test around the call is not needed.
>>>>
>>>> This issue was detected by using the Coccinelle software.
>>>>
>>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>>> ---
>>>> drivers/net/ieee802154/atusb.c | 3 +--
>>>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/net/ieee802154/atusb.c b/drivers/net/ieee802154/atusb.c
>>>> index 199a94a..b1cd865 100644
>>>> --- a/drivers/net/ieee802154/atusb.c
>>>> +++ b/drivers/net/ieee802154/atusb.c
>>>> @@ -310,8 +310,7 @@ static void atusb_free_urbs(struct atusb *atusb)
>>>>          urb = usb_get_from_anchor(&atusb->idle_urbs);
>>>>          if (!urb)
>>>>              break;
>>>> -        if (urb->context)
>>>> -            kfree_skb(urb->context);
>>>> +        kfree_skb(urb->context);
>>>>          usb_free_urb(urb);
>>>>      }
>>>> }
>>> Acked-by: Stefan Schmidt <stefan@osg.samsung.com>
>>
>> You got the original patch and my ACK on this one or would you prefer me to resend it again?
> this slipped through, but now it does no longer apply.
>
> Applying: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
> error: patch failed: drivers/net/ieee802154/atusb.c:310
> error: drivers/net/ieee802154/atusb.c: patch does not apply
> Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"

Not good. I did another resend, this one applied, compiled and worked 
fine for me. You will be in the to line.

regards
Stefan Schmidt

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

* Re: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-12-10 18:16                                         ` Marcel Holtmann
  2015-12-10 22:45                                           ` Stefan Schmidt
@ 2015-12-11 13:07                                           ` SF Markus Elfring
  2015-12-11 13:21                                             ` Stefan Schmidt
  1 sibling, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2015-12-11 13:07 UTC (permalink / raw)
  To: Marcel Holtmann, Stefan Schmidt
  Cc: Alexander Aring, linux-wpan, Network Development, LKML,
	kernel-janitors, Julia Lawall

> this slipped through, but now it does no longer apply.
> 
> Applying: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
> error: patch failed: drivers/net/ieee802154/atusb.c:310
> error: drivers/net/ieee802154/atusb.c: patch does not apply
> Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"

How can this hiccup happen?

A command like the following is still working for me on source files
for the software "Linux next-20151211".

elfring@Sonne:~/Projekte/Linux/next-patched> git apply ~/Projekte/Bau/Linux/scripts/Coccinelle/deletions1/next/20151113/Flicken/0001-ieee802154-atusb-Delete-an-unnecessary-check-before.patch

Regards,
Markus

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

* Re: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
  2015-12-11 13:07                                           ` SF Markus Elfring
@ 2015-12-11 13:21                                             ` Stefan Schmidt
  0 siblings, 0 replies; 273+ messages in thread
From: Stefan Schmidt @ 2015-12-11 13:21 UTC (permalink / raw)
  To: SF Markus Elfring, Marcel Holtmann
  Cc: Alexander Aring, linux-wpan, Network Development, LKML,
	kernel-janitors, Julia Lawall

Hello.

On 11/12/15 14:07, SF Markus Elfring wrote:
>> this slipped through, but now it does no longer apply.
>>
>> Applying: ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
>> error: patch failed: drivers/net/ieee802154/atusb.c:310
>> error: drivers/net/ieee802154/atusb.c: patch does not apply
>> Patch failed at 0001 ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb"
> How can this hiccup happen?
>

I might have been a problem when I was resending your patch the first 
time as Marcel was not able to find the original one.

I have send it a second time now and it worked fine. The patch is 
already applied to the bluetooth-next tree and thus on its way. All good 
now.

https://git.kernel.org/cgit/linux/kernel/git/bluetooth/bluetooth-next.git/commit/?id=4188146566a9f1d57dfce77fd9457f7304b69dfa

regards
Stefan Schmidt

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

* [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
       [not found]                                             ` <1655341.WCvHHx7pqD@bentobox>
@ 2016-03-11 12:40                                               ` SF Markus Elfring
  2016-03-14 19:25                                                 ` David Miller
  0 siblings, 1 reply; 273+ messages in thread
From: SF Markus Elfring @ 2016-03-11 12:40 UTC (permalink / raw)
  To: b.a.t.m.a.n, netdev, Antonio Quartulli, David S. Miller,
	Marek Lindner, Simon Wunderlich, Sven Eckelmann
  Cc: linux-kernel, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Mar 2016 13:10:20 +0100

The variables "tt_local_entry" and "tt_global_entry" were eventually
checked again despite of a corresponding null pointer test before.

* Avoid this double check by reordering a function call sequence
  and the better selection of jump targets.

* Omit the initialisation for these variables at the beginning then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/translation-table.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 0b43e86..9c0193ee 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3403,8 +3403,8 @@ void batadv_tt_local_commit_changes(struct batadv_priv *bat_priv)
 bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 			   unsigned short vid)
 {
-	struct batadv_tt_local_entry *tt_local_entry = NULL;
-	struct batadv_tt_global_entry *tt_global_entry = NULL;
+	struct batadv_tt_local_entry *tt_local_entry;
+	struct batadv_tt_global_entry *tt_global_entry;
 	struct batadv_softif_vlan *vlan;
 	bool ret = false;
 
@@ -3413,27 +3413,24 @@ bool batadv_is_ap_isolated(struct batadv_priv *bat_priv, u8 *src, u8 *dst,
 		return false;
 
 	if (!atomic_read(&vlan->ap_isolation))
-		goto out;
+		goto vlan_put;
 
 	tt_local_entry = batadv_tt_local_hash_find(bat_priv, dst, vid);
 	if (!tt_local_entry)
-		goto out;
+		goto vlan_put;
 
 	tt_global_entry = batadv_tt_global_hash_find(bat_priv, src, vid);
 	if (!tt_global_entry)
-		goto out;
-
-	if (!_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
-		goto out;
+		goto local_entry_put;
 
-	ret = true;
+	if (_batadv_is_ap_isolated(tt_local_entry, tt_global_entry))
+		ret = true;
 
-out:
+	batadv_tt_global_entry_put(tt_global_entry);
+local_entry_put:
+	batadv_tt_local_entry_put(tt_local_entry);
+vlan_put:
 	batadv_softif_vlan_put(vlan);
-	if (tt_global_entry)
-		batadv_tt_global_entry_put(tt_global_entry);
-	if (tt_local_entry)
-		batadv_tt_local_entry_put(tt_local_entry);
 	return ret;
 }
 
-- 
2.7.2

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

* Re: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
  2016-03-11 12:40                                               ` [PATCH] " SF Markus Elfring
@ 2016-03-14 19:25                                                 ` David Miller
  2016-03-15  0:14                                                   ` Antonio Quartulli
  0 siblings, 1 reply; 273+ messages in thread
From: David Miller @ 2016-03-14 19:25 UTC (permalink / raw)
  To: elfring
  Cc: b.a.t.m.a.n, netdev, a, mareklindner, sw, sven, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Mar 2016 13:40:56 +0100

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 11 Mar 2016 13:10:20 +0100
> 
> The variables "tt_local_entry" and "tt_global_entry" were eventually
> checked again despite of a corresponding null pointer test before.
> 
> * Avoid this double check by reordering a function call sequence
>   and the better selection of jump targets.
> 
> * Omit the initialisation for these variables at the beginning then.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

I am assuming Antonio will take this in via his tree.

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

* Re: [PATCH] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
  2016-03-14 19:25                                                 ` David Miller
@ 2016-03-15  0:14                                                   ` Antonio Quartulli
  0 siblings, 0 replies; 273+ messages in thread
From: Antonio Quartulli @ 2016-03-15  0:14 UTC (permalink / raw)
  To: David Miller
  Cc: elfring, b.a.t.m.a.n, netdev, mareklindner, sw, sven,
	linux-kernel, kernel-janitors, julia.lawall

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

On Mon, Mar 14, 2016 at 03:25:02PM -0400, David Miller wrote:
> From: SF Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 11 Mar 2016 13:40:56 +0100
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Fri, 11 Mar 2016 13:10:20 +0100
> > 
> > The variables "tt_local_entry" and "tt_global_entry" were eventually
> > checked again despite of a corresponding null pointer test before.
> > 
> > * Avoid this double check by reordering a function call sequence
> >   and the better selection of jump targets.
> > 
> > * Omit the initialisation for these variables at the beginning then.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> I am assuming Antonio will take this in via his tree.
> 

Yeah, it will go through our tree. Still under review right now.

Cheers,

-- 
Antonio Quartulli

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb"
  2015-11-16 10:22                                   ` [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
@ 2016-07-19 20:11                                     ` SF Markus Elfring
  0 siblings, 0 replies; 273+ messages in thread
From: SF Markus Elfring @ 2016-07-19 20:11 UTC (permalink / raw)
  To: Inaky Perez-Gonzalez, linux-wimax, netdev
  Cc: LKML, kernel-janitors, Julia Lawall

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 16 Nov 2015 11:17:55 +0100
> 
> The kfree_skb() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/wimax/i2400m/control.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c
> index 4c41790..4de22b7 100644
> --- a/drivers/net/wimax/i2400m/control.c
> +++ b/drivers/net/wimax/i2400m/control.c
> @@ -644,7 +644,7 @@ void i2400m_msg_to_dev_cancel_wait(struct i2400m *i2400m, int code)
>  
>  	spin_lock_irqsave(&i2400m->rx_lock, flags);
>  	ack_skb = i2400m->ack_skb;
> -	if (ack_skb && !IS_ERR(ack_skb))
> +	if (!IS_ERR(ack_skb))
>  		kfree_skb(ack_skb);
>  	i2400m->ack_skb = ERR_PTR(code);
>  	spin_unlock_irqrestore(&i2400m->rx_lock, flags);
> 

How do you think about to integrate this update suggestion
into another source code repository?

Regards,
Markus

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

end of thread, other threads:[~2016-07-19 20:11 UTC | newest]

Thread overview: 273+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5307CAA2.8060406@users.sourceforge.net>
     [not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
     [not found]   ` <530A086E.8010901@users.sourceforge.net>
     [not found]     ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
     [not found]       ` <530A72AA.3000601@users.sourceforge.net>
     [not found]         ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
     [not found]           ` <530B5FB6.6010207@users.sourceforge.net>
     [not found]             ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
     [not found]               ` <530C5E18.1020800@users.sourceforge.net>
     [not found]                 ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
     [not found]                   ` <530CD2C4.4050903@users.sourceforge.net>
     [not found]                     ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
     [not found]                       ` <530CF8FF.8080600@users.sourceforge.net>
     [not found]                         ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
     [not found]                           ` <530DD06F.4090703@users.sourceforge.net>
     [not found]                             ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
     [not found]                               ` <5317A59D.4@users.so urceforge.net>
     [not found]                                 ` <5317A59D.4-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-02-04 14:22                                   ` [PATCH] net: Mellanox: Delete unnecessary checks before the function call "vunmap" SF Markus Elfring
2015-02-04 14:59                                     ` Eli Cohen
     [not found]                                     ` <54D22B29.3020200-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-02-05  8:34                                       ` David Miller
     [not found]                                         ` <20150205.003404.261962007607296519.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2015-02-09 10:21                                           ` [PATCH v2] " SF Markus Elfring
2015-02-09 22:10                                             ` David Miller
2015-11-15  8:40                                   ` [PATCH 0/2] batman-adv: Deletion of some unnecessary checks SF Markus Elfring
2015-11-15  8:43                                     ` [PATCH 1/2] batman-adv: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
2015-11-21 21:45                                       ` [B.A.T.M.A.N.] " Marek Lindner
2015-11-15  8:45                                     ` [PATCH 2/2] batman-adv: Less checks in batadv_tvlv_unicast_send() SF Markus Elfring
2015-11-21 21:47                                       ` [B.A.T.M.A.N.] " Marek Lindner
     [not found]                                 ` <5317A59D.4@users.sourceforge.net>
2014-11-18 19:16                                   ` [PATCH 1/1] net: pktgen: Deletion of an unnecessary check before the function call "proc_remove" SF Markus Elfring
2014-11-19 20:20                                     ` David Miller
2014-11-18 19:47                                   ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-19 13:40                                     ` Pablo Neira Ayuso
2015-07-02 15:10                                       ` [PATCH] net-ipvs: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
2015-07-09  1:41                                         ` Simon Horman
2014-11-19 22:26                                     ` [PATCH 1/1] netfilter: Deletion of unnecessary checks before two function calls Julian Anastasov
2014-11-20  1:13                                       ` Simon Horman
2014-11-20 12:16                                         ` Pablo Neira Ayuso
2014-11-18 20:08                                   ` [PATCH 1/1] netlink: Deletion of an unnecessary check before the function call "__module_get" SF Markus Elfring
2014-11-19 20:28                                     ` David Miller
2014-11-18 20:26                                   ` [PATCH 1/1] net: sched: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
2014-11-19 16:47                                     ` John Fastabend
2014-11-19 17:00                                       ` Daniel Borkmann
2014-11-19 18:49                                       ` SF Markus Elfring
2014-11-19 19:09                                         ` Daniel Borkmann
2014-11-20  8:47                                         ` Julia Lawall
2014-11-20  9:22                                           ` Daniel Borkmann
2014-11-18 20:45                                   ` [PATCH 1/1] net: xfrm: Deletion of an unnecessary check before the function call "ipcomp_free_tfms" SF Markus Elfring
2014-11-19  8:45                                     ` Dan Carpenter
2014-11-19  9:51                                       ` SF Markus Elfring
2014-11-19  9:58                                         ` Julia Lawall
2014-11-19 10:10                                         ` Dan Carpenter
2014-11-19 18:19                                           ` David Miller
2014-11-19 19:55                                   ` [PATCH 1/1] mISDN: Deletion of unnecessary checks before the function call "vfree" SF Markus Elfring
2014-11-19 21:54                                     ` David Miller
2014-11-20 13:28                                   ` [PATCH 1/1] IBM-EMAC: Deletion of unnecessary checks before the function call "of_dev_put" SF Markus Elfring
2014-11-21 20:14                                     ` David Miller
2014-11-20 13:50                                   ` [PATCH 1/1] net: Xilinx: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 17:29                                     ` Sören Brinkmann
2014-11-21 20:14                                     ` David Miller
2014-11-20 14:25                                   ` [PATCH 1/1] net: Hyper-V: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-20 18:58                                     ` Haiyang Zhang
2014-11-21 20:15                                     ` David Miller
2014-11-21 22:15                                       ` SF Markus Elfring
2014-11-21 22:27                                         ` David Miller
2014-11-23  0:51                                           ` SF Markus Elfring
2014-11-23  1:27                                             ` Eric Dumazet
2014-11-23  7:01                                               ` SF Markus Elfring
2014-11-23  4:36                                             ` David Miller
2014-11-23  7:18                                               ` SF Markus Elfring
2014-11-23 18:37                                                 ` David Miller
2014-11-25 21:55                                       ` [PATCH v2] " SF Markus Elfring
2014-11-25 22:25                                         ` David Miller
2014-11-20 15:16                                   ` [PATCH 1/1] net: USB: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
2014-11-21 20:16                                     ` David Miller
2014-11-20 15:50                                   ` [PATCH 1/1] net: brcm80211: Deletion of unnecessary checks before two function calls SF Markus Elfring
2014-11-20 18:04                                     ` Arend van Spriel
2015-11-06  7:58                                       ` [PATCH] net: brcm80211: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
2015-11-11  9:18                                         ` Arend van Spriel
     [not found]                                         ` <563C5DA2.3000005-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-11-26 12:04                                           ` brcm80211: Delete an unnecessary check before the function call"release_firmware" Kalle Valo
2014-11-29 13:42                                   ` [PATCH 1/1] HID: Wacom: Deletion of an unnecessary check before the function call "vfree" SF Markus Elfring
2014-11-29 14:05                                     ` [PATCH 1/1] net: cassini: " SF Markus Elfring
2014-12-06  5:14                                       ` David Miller
2014-11-29 15:30                                   ` [PATCH 1/1] net-ipvlan: Deletion of an unnecessary check before the function call "free_percpu" SF Markus Elfring
2014-12-02  0:01                                     ` Mahesh Bandewar
2014-12-06  5:14                                     ` David Miller
2014-11-29 18:00                                   ` [PATCH 1/1] net-PA Semi: Deletion of unnecessary checks before the function call "pci_dev_put" SF Markus Elfring
2014-11-30 17:45                                     ` Lino Sanfilippo
2014-11-30 17:47                                       ` Julia Lawall
2014-11-30 19:27                                         ` Lino Sanfilippo
2014-11-30 20:40                                           ` SF Markus Elfring
2014-11-30 21:36                                             ` Lino Sanfilippo
     [not found]                                       ` <547B579F.10709-Mmb7MZpHnFY@public.gmane.org>
2014-12-01  1:34                                         ` SF Markus Elfring
2014-12-01 20:29                                           ` Johannes Berg
2014-12-01 20:34                                             ` Julia Lawall
     [not found]                                               ` <alpine.DEB.2.02.1412012134290.2076-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2014-12-02 16:53                                                 ` Johannes Berg
     [not found]                                                   ` <1417539208.1841.1.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2014-12-02 18:35                                                     ` Dan Carpenter
2014-12-02 20:18                                                       ` Luis R. Rodriguez
2014-12-02 18:45                                                   ` Luis R. Rodriguez
2014-12-01 20:36                                     ` [PATCH 1/1] " Olof Johansson
2014-12-06  5:15                                     ` David Miller
2014-11-30 16:40                                   ` [PATCH 0/3] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
2014-11-30 16:44                                     ` [PATCH 1/3] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
2014-12-01 12:19                                       ` Sergei Shtylyov
2014-12-01 15:00                                         ` SF Markus Elfring
2014-12-01 17:11                                           ` Sergei Shtylyov
2014-12-04 22:03                                             ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks SF Markus Elfring
2014-12-04 22:10                                               ` [PATCH v2 1/6] net-PPP: Replacement of a printk() call by pr_warn() in mppe_rekey() SF Markus Elfring
2014-12-04 22:23                                                 ` Joe Perches
2014-12-04 22:27                                                   ` SF Markus Elfring
2014-12-04 22:45                                                     ` Joe Perches
2014-12-05  6:26                                                       ` Julia Lawall
2014-12-05  8:04                                                         ` SF Markus Elfring
2014-12-05  8:40                                                           ` Julia Lawall
2014-12-05  7:18                                                       ` SF Markus Elfring
2014-12-05  7:57                                                         ` Joe Perches
2014-12-05  8:49                                                           ` SF Markus Elfring
2014-12-05 22:35                                                           ` terry white
2014-12-05  7:21                                                   ` Julia Lawall
2014-12-05  7:41                                                     ` Joe Perches
2014-12-07 10:44                                                       ` Julia Lawall
2014-12-07 12:30                                                         ` Joe Perches
2014-12-07 12:36                                                           ` Julia Lawall
2014-12-07 12:42                                                             ` Joe Perches
2014-12-04 22:13                                               ` [PATCH v2 2/6] net-PPP: Fix indentation SF Markus Elfring
2014-12-04 22:15                                               ` [PATCH v2 3/6] net-PPP: Deletion of unnecessary checks before the function call "kfree" SF Markus Elfring
2014-12-04 22:16                                               ` [PATCH v2 4/6] net-PPP: Less function calls in mppe_alloc() after error detection SF Markus Elfring
2014-12-04 22:18                                               ` [PATCH v2 5/6] net-PPP: Delete an unnecessary assignment in mppe_alloc() SF Markus Elfring
2014-12-05 12:22                                                 ` Dan Carpenter
2014-12-05 12:44                                                   ` SF Markus Elfring
2014-12-05 13:57                                                     ` Dan Carpenter
2014-12-05 21:00                                                       ` SF Markus Elfring
2014-12-04 22:20                                               ` [PATCH v2 6/6] net-PPP: Delete another " SF Markus Elfring
2014-12-05 12:23                                                 ` Dan Carpenter
2014-12-05 12:50                                                   ` SF Markus Elfring
2014-12-05 13:58                                                   ` Dan Carpenter
2014-12-09 19:54                                               ` [PATCH v2 0/6] net-PPP: Deletion of a few unnecessary checks David Miller
2014-12-12  7:01                                                 ` SF Markus Elfring
2014-12-12 14:29                                                   ` David Miller
2014-12-12 15:30                                                     ` SF Markus Elfring
2014-12-12 15:51                                                       ` David Miller
2014-12-12 16:56                                                         ` SF Markus Elfring
2014-12-12 16:59                                                           ` David Miller
2014-12-12 17:22                                                             ` SF Markus Elfring
2014-12-12 19:08                                                               ` Eric Dumazet
2014-12-13  6:05                                                                 ` SF Markus Elfring
2014-12-12 20:07                                                               ` David Miller
2014-12-13  6:17                                                                 ` SF Markus Elfring
2014-12-18 17:23                                                             ` SF Markus Elfring
2014-12-18 17:25                                                               ` David Miller
2014-12-18 17:44                                                                 ` SF Markus Elfring
2014-12-20 14:45                                                                 ` SF Markus Elfring
2014-12-20 15:48                                                                   ` Lino Sanfilippo
2014-12-20 16:17                                                                     ` SF Markus Elfring
2014-12-20 19:30                                                                   ` David Miller
2014-12-12 18:46                                                       ` Julia Lawall
2014-11-30 16:45                                     ` [PATCH 2/3] net-PPP: Less function calls in mppe_alloc() after error detection SF Markus Elfring
2014-11-30 16:47                                     ` [PATCH 3/3] net-PPP: Delete an unnecessary assignment SF Markus Elfring
2014-11-30 19:59                                       ` Eric Dumazet
2014-11-30 21:16                                         ` SF Markus Elfring
2015-01-31 16:34                                   ` [PATCH] net: sched: One function call less in em_meta_change() after error detection SF Markus Elfring
2015-01-31 17:31                                     ` Lino Sanfilippo
2015-01-31 21:48                                       ` SF Markus Elfring
2015-01-31 22:15                                         ` Lino Sanfilippo
2015-01-31 22:20                                           ` SF Markus Elfring
2015-01-31 22:51                                             ` Lino Sanfilippo
2015-01-31 17:50                                     ` Lino Sanfilippo
2015-01-31 21:52                                       ` SF Markus Elfring
2015-01-31 22:09                                         ` Lino Sanfilippo
2015-02-04  0:10                                     ` David Miller
2015-02-04  9:54                                       ` SF Markus Elfring
2015-01-31 17:15                                   ` [PATCH] net: sctp: Deletion of an unnecessary check before the function call "kfree" SF Markus Elfring
2015-01-31 18:38                                     ` Neil Horman
2015-02-03  3:30                                     ` David Miller
2015-01-31 21:14                                   ` [PATCH 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
2015-01-31 21:34                                     ` [PATCH 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
2015-02-01  2:20                                       ` Paul Moore
2015-01-31 21:36                                     ` [PATCH 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
2015-02-01  2:22                                       ` Paul Moore
2015-01-31 21:38                                     ` [PATCH 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
2015-02-01  2:40                                       ` Paul Moore
2015-02-01 10:15                                         ` [PATCH v2 " SF Markus Elfring
2015-02-01 14:39                                           ` Paul Moore
2015-02-01 20:30                                           ` David Miller
2015-02-02 10:22                                             ` [PATCH v3 0/3] netlabel: Deletion of a few unnecessary checks SF Markus Elfring
2015-02-02 10:25                                               ` [PATCH v3 1/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_putdef" SF Markus Elfring
2015-02-02 10:26                                               ` [PATCH v3 2/3] netlabel: Deletion of an unnecessary check before the function call "cipso_v4_doi_free" SF Markus Elfring
2015-02-02 11:06                                               ` [PATCH v3 3/3] netlabel: Less function calls in netlbl_mgmt_add_common() after error detection SF Markus Elfring
2015-02-03 18:51                                   ` [PATCH] IBM-EMAC: Delete an unnecessary check before the function call "of_dev_put" SF Markus Elfring
2015-02-05  4:29                                     ` David Miller
2015-02-03 19:22                                   ` [PATCH] NetCP: Deletion of unnecessary checks before two function calls SF Markus Elfring
2015-02-05  4:30                                     ` David Miller
2015-02-05 12:01                                     ` Dan Carpenter
2015-02-05 15:50                                       ` Kwok, WingMan
2015-02-04 10:38                                   ` [PATCH] cxgb4: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
2015-02-05  8:07                                     ` David Miller
2015-02-04 11:36                                   ` [PATCH] myri10ge: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2015-02-05  8:25                                     ` David Miller
2015-02-04 12:00                                   ` [PATCH] net: fec: Delete unnecessary checks " SF Markus Elfring
2015-02-05  8:26                                     ` David Miller
2015-02-04 12:21                                   ` [PATCH] netxen: Delete an unnecessary check " SF Markus Elfring
2015-02-05  8:26                                     ` David Miller
2015-02-04 13:13                                   ` [PATCH] qlogic: Deletion of unnecessary checks before two function calls SF Markus Elfring
2015-02-05  8:33                                     ` David Miller
2015-02-04 15:00                                   ` [PATCH] net: ep93xx_eth: Delete unnecessary checks before the function call "kfree" SF Markus Elfring
2015-02-04 15:59                                     ` Hartley Sweeten
2015-02-05  8:37                                     ` David Miller
2015-02-04 16:45                                   ` [PATCH 0/2] CW1200: Deletion of an unnecessary check SF Markus Elfring
2015-02-04 16:47                                     ` [PATCH 1/2] CW1200: Delete an unnecessary check before the function call "release_firmware" SF Markus Elfring
2015-02-06  6:49                                       ` [1/2] cw1200: " Kalle Valo
2015-02-04 16:48                                     ` [PATCH 2/2] CW1200: Less function calls in cw1200_load_firmware_cw1200() after error detection SF Markus Elfring
2015-02-04 17:54                                   ` [PATCH] ath9k: Delete an unnecessary check before the function call "relay_close" SF Markus Elfring
2015-02-06  6:50                                     ` ath9k: Delete an unnecessary check before the function call"relay_close" Kalle Valo
2015-02-04 18:33                                   ` [PATCH] ath10k: Delete unnecessary checks before the function call "release_firmware" SF Markus Elfring
2015-03-04 12:06                                     ` Kalle Valo
2015-02-04 18:56                                   ` [PATCH] orinoco: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2015-02-06  6:51                                     ` Kalle Valo
2015-02-04 19:10                                   ` [PATCH] HostAP: " SF Markus Elfring
2015-02-06  6:52                                     ` hostap: " Kalle Valo
2015-02-04 19:40                                   ` [PATCH] net: brcm80211: Delete unnecessary checks before two function calls SF Markus Elfring
2015-02-06  6:53                                     ` Kalle Valo
2015-06-29 10:48                                   ` [PATCH] net-Liquidio: Delete unnecessary checks before the function call "vfree" SF Markus Elfring
2015-06-29 16:28                                     ` David Miller
2015-07-02 14:43                                   ` [PATCH] net-ipv6: Delete an unnecessary check before the function call "free_percpu" SF Markus Elfring
2015-07-03 16:28                                     ` David Miller
2015-07-02 16:08                                   ` [PATCH] net-RDS: Delete an unnecessary check before the function call "module_put" SF Markus Elfring
2015-07-03 16:28                                     ` David Miller
2015-07-02 16:45                                   ` [PATCH] netlink: " SF Markus Elfring
2015-07-03 16:28                                     ` David Miller
2015-11-03 17:30                                   ` [PATCH] irda: Delete an unnecessary check before the function call "irlmp_unregister_service" SF Markus Elfring
2015-11-03 18:31                                     ` David Miller
2015-11-03 20:45                                   ` [PATCH 0/3] batman-adv: Deletion of a few unnecessary checks SF Markus Elfring
2015-11-03 20:52                                     ` [PATCH 1/3] batman-adv: Delete an unnecessary check before the function call "batadv_softif_vlan_free_ref" SF Markus Elfring
2015-11-21 21:48                                       ` [B.A.T.M.A.N.] " Marek Lindner
2015-11-03 20:54                                     ` [PATCH 2/3] batman-adv: Split a condition check SF Markus Elfring
2015-11-21 21:51                                       ` [B.A.T.M.A.N.] " Marek Lindner
2015-11-03 20:56                                     ` [PATCH 3/3] batman-adv: Less function calls in batadv_is_ap_isolated() after error detection SF Markus Elfring
2015-11-20  8:47                                       ` [B.A.T.M.A.N.] " Antonio Quartulli
     [not found]                                       ` <564EDE1D.7070809@meshcoding.com>
     [not found]                                         ` <564EDE1D.7070809-x4xJYDvStAgysxA8WJXlww@public.gmane.org>
2015-11-20 10:56                                           ` SF Markus Elfring
     [not found]                                             ` <1655341.WCvHHx7pqD@bentobox>
2016-03-11 12:40                                               ` [PATCH] " SF Markus Elfring
2016-03-14 19:25                                                 ` David Miller
2016-03-15  0:14                                                   ` Antonio Quartulli
2015-11-06  7:15                                   ` [PATCH] DWC Ethernet QoS: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
2015-11-07  4:33                                     ` David Miller
2015-11-07 14:15                                       ` [PATCH] ethernet-synopsys: Delete an unnecessary check before of_node_put() SF Markus Elfring
2015-11-07 14:50                                         ` David Miller
2015-11-07 15:34                                       ` [PATCH] dwc_eth_qos: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
2015-11-07 18:19                                         ` David Miller
2015-11-06  8:39                                   ` [PATCH] fjes: Delete an unnecessary check before the function call "vfree" SF Markus Elfring
2015-11-07 18:18                                     ` David Miller
2015-11-14 17:12                                   ` [PATCH] net: dsa: Delete an unnecessary check before the function call "put_device" SF Markus Elfring
2015-11-16 20:11                                     ` David Miller
2015-11-14 19:05                                   ` [PATCH] net-ipv6: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
2015-11-15  3:32                                     ` Eric Dumazet
2015-11-15  6:17                                       ` SF Markus Elfring
2015-11-14 19:27                                   ` [PATCH] mac802154: Delete an unnecessary check " SF Markus Elfring
2015-11-15  0:20                                     ` Marcel Holtmann
2015-11-14 21:10                                   ` [PATCH] Bluetooth-cmtp: " SF Markus Elfring
     [not found]                                     ` <5647A33E.3030103-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
2015-11-15  0:21                                       ` Marcel Holtmann
2015-11-14 21:28                                   ` [PATCH] net-hsr: Delete unnecessary checks " SF Markus Elfring
2015-11-24 13:42                                     ` Arvid Brodin
2015-11-14 21:50                                   ` [PATCH] NFC-nci: " SF Markus Elfring
2015-11-16  9:43                                   ` [PATCH 0/2] mISDN: Deletion of an unnecessary check SF Markus Elfring
2015-11-16  9:45                                     ` [PATCH 1/2] mISDN: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
2015-11-16  9:47                                     ` [PATCH 2/2] mISDN: One function call less in mISDN_sock_sendmsg() after error detection SF Markus Elfring
2015-11-16 10:22                                   ` [PATCH] WiMAX-i2400m: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
2016-07-19 20:11                                     ` SF Markus Elfring
2015-11-16 11:28                                   ` [PATCH] ixp4xx_eth: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
2015-11-25 12:19                                     ` Krzysztof Hałasa
2015-11-16 11:52                                   ` [PATCH] cxgb3: Delete unnecessary checks before the function call "kfree_skb" SF Markus Elfring
2015-11-16 12:18                                   ` [PATCH] rtlwifi: " SF Markus Elfring
2015-11-26 13:01                                     ` rtlwifi: Delete unnecessary checks before the function call"kfree_skb" Kalle Valo
2015-11-16 12:36                                   ` [PATCH] ixp4xx_hss: Delete an unnecessary check before the function call "dma_pool_destroy" SF Markus Elfring
2015-11-25 12:19                                     ` Krzysztof Hałasa
2015-11-16 12:57                                   ` [PATCH] ieee802154-atusb: Delete an unnecessary check before the function call "kfree_skb" SF Markus Elfring
2015-11-16 13:46                                     ` Stefan Schmidt
2015-11-17 14:01                                       ` Marcel Holtmann
2015-11-17 16:19                                         ` Stefan Schmidt
2015-11-17 16:17                                   ` Stefan Schmidt
2015-11-17 16:18                                     ` Stefan Schmidt
2015-12-10 10:14                                       ` Stefan Schmidt
2015-12-10 18:16                                         ` Marcel Holtmann
2015-12-10 22:45                                           ` Stefan Schmidt
2015-12-11 13:07                                           ` SF Markus Elfring
2015-12-11 13:21                                             ` Stefan Schmidt
2015-11-17 16:43                                   ` [PATCH] net-scm: Delete an unnecessary check before the function call "kfree" SF Markus Elfring
2015-11-17 17:10                                     ` David Miller
2015-11-17 17:13                                     ` Daniel Borkmann
2015-11-17 18:05                                       ` SF Markus Elfring
2015-11-17 18:37                                         ` Daniel Borkmann
2015-11-18  7:45                                           ` net-scm: Macro for special pattern? SF Markus Elfring
2015-11-18 12:43                                             ` Eric Dumazet

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).