* [PATCH 0/2] net/sched/cls_tcindex: Fine-tuning for two function implementations
@ 2017-11-08 20:34 SF Markus Elfring
2017-11-08 20:36 ` [PATCH 1/2] net/sched/cls_tcindex: Use common error handling code in tcindex_set_parms() SF Markus Elfring
2017-11-08 20:38 ` [PATCH 2/2] net/sched/cls_tcindex: Improve a size determination in two functions SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-11-08 20:34 UTC (permalink / raw)
To: netdev, Cong Wang, David S. Miller, Jamal Hadi Salim, Jiri Pirko
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Nov 2017 21:30:03 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use common error handling code in tcindex_set_parms()
Improve a size determination in two functions
net/sched/cls_tcindex.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
--
2.15.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] net/sched/cls_tcindex: Use common error handling code in tcindex_set_parms()
2017-11-08 20:34 [PATCH 0/2] net/sched/cls_tcindex: Fine-tuning for two function implementations SF Markus Elfring
@ 2017-11-08 20:36 ` SF Markus Elfring
2017-11-08 20:38 ` [PATCH 2/2] net/sched/cls_tcindex: Improve a size determination in two functions SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-11-08 20:36 UTC (permalink / raw)
To: netdev, Cong Wang, David S. Miller, Jamal Hadi Salim, Jiri Pirko
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Nov 2017 21:10:49 +0100
Add a jump target so that a bit of exception handling can be better reused
at the end of this function.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sched/cls_tcindex.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index d6abfa6757f2..24f05bc09084 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -437,10 +437,8 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
f->key = handle;
f->next = NULL;
err = tcindex_filter_result_init(&f->result);
- if (err < 0) {
- kfree(f);
- goto errout_alloc;
- }
+ if (err < 0)
+ goto err_free_filter;
}
if (tb[TCA_TCINDEX_CLASSID]) {
@@ -455,10 +453,8 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
if (old_r && old_r != r) {
err = tcindex_filter_result_init(old_r);
- if (err < 0) {
- kfree(f);
- goto errout_alloc;
- }
+ if (err < 0)
+ goto err_free_filter;
}
oldp = p;
@@ -484,6 +480,8 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
call_rcu(&oldp->rcu, __tcindex_partial_destroy);
return 0;
+err_free_filter:
+ kfree(f);
errout_alloc:
if (balloc == 1)
tcindex_free_perfect_hash(cp);
--
2.15.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] net/sched/cls_tcindex: Improve a size determination in two functions
2017-11-08 20:34 [PATCH 0/2] net/sched/cls_tcindex: Fine-tuning for two function implementations SF Markus Elfring
2017-11-08 20:36 ` [PATCH 1/2] net/sched/cls_tcindex: Use common error handling code in tcindex_set_parms() SF Markus Elfring
@ 2017-11-08 20:38 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-11-08 20:38 UTC (permalink / raw)
To: netdev, Cong Wang, David S. Miller, Jamal Hadi Salim, Jiri Pirko
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Nov 2017 21:17:26 +0100
Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sched/cls_tcindex.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
index 24f05bc09084..0f1909c6545d 100644
--- a/net/sched/cls_tcindex.c
+++ b/net/sched/cls_tcindex.c
@@ -130,7 +130,7 @@ static int tcindex_init(struct tcf_proto *tp)
struct tcindex_data *p;
pr_debug("tcindex_init(tp %p)\n", tp);
- p = kzalloc(sizeof(struct tcindex_data), GFP_KERNEL);
+ p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -413,10 +413,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
} else {
struct tcindex_filter __rcu **hash;
- hash = kcalloc(cp->hash,
- sizeof(struct tcindex_filter *),
- GFP_KERNEL);
-
+ hash = kcalloc(cp->hash, sizeof(*hash), GFP_KERNEL);
if (!hash)
goto errout_alloc;
--
2.15.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-08 20:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-08 20:34 [PATCH 0/2] net/sched/cls_tcindex: Fine-tuning for two function implementations SF Markus Elfring
2017-11-08 20:36 ` [PATCH 1/2] net/sched/cls_tcindex: Use common error handling code in tcindex_set_parms() SF Markus Elfring
2017-11-08 20:38 ` [PATCH 2/2] net/sched/cls_tcindex: Improve a size determination in two functions SF Markus Elfring
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).