net: sched: cls_basic: fix error path in basic_change()
Subsystems (3)
Jiri Pirko
maintainerPATCH 1/2 net: sched: cls_basic: fix error path in basic_change()
--- net/sched/cls_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/sched/cls_basic.c +2 -3
@@ -178,10 +178,9 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; } - err = -ENOBUFS ; fnew =kzalloc (sizeof (*fnew),GFP_KERNEL ); -if (fnew ==NULL ) - goto errout; +if (!fnew) +return -ENOBUFS ;tcf_exts_init (&fnew->exts,TCA_BASIC_ACT ,TCA_BASIC_POLICE ); err = -EINVAL ;
Signature · 1 line
1.9.3
Jiri Pirko
maintainerPATCH 2/2 net: sched: cls: use nla_nest_cancel instead of nlmsg_trim
To cancel nesting, this function is more convenient.
--- net/sched/cls_cgroup.c | 3 +-- net/sched/cls_flow.c | 2 +- net/sched/cls_fw.c | 3 +-- net/sched/cls_route.c | 3 +-- net/sched/cls_rsvp.h | 3 +-- net/sched/cls_tcindex.c | 3 +-- 6 files changed, 6 insertions(+), 11 deletions(-)
net/sched/cls_cgroup.c +1 -2
@@ -177,7 +177,6 @@ static int cls_cgroup_dump(struct net *net, struct tcf_proto *tp, unsigned long struct sk_buff *skb, struct tcmsg *t) { struct cls_cgroup_head *head = rtnl_dereference(tp->root); -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest; t->tcm_handle = head->handle;
@@ -198,7 +197,7 @@ static int cls_cgroup_dump(struct net *net, struct tcf_proto *tp, unsigned longreturn skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_flow.c +1 -1
@@ -638,7 +638,7 @@ static int flow_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, nest); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_fw.c +1 -2
@@ -356,7 +356,6 @@ static int fw_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, {struct fw_head *head =rtnl_dereference (tp->root);struct fw_filter *f = (struct fw_filter *)fh; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest;if (f ==NULL )
@@ -397,7 +396,7 @@ static int fw_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_route.c +1 -2
@@ -593,7 +593,6 @@ static int route4_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { struct route4_filter *f = (struct route4_filter *)fh; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest;u32 id;
@@ -635,7 +634,7 @@ static int route4_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_rsvp.h +1 -2
@@ -653,7 +653,6 @@ static int rsvp_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, {struct rsvp_filter *f = (struct rsvp_filter *)fh;struct rsvp_session *s; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest;struct tc_rsvp_pinfo pinfo;
@@ -694,7 +693,7 @@ static int rsvp_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_tcindex.c +1 -2
@@ -489,7 +489,6 @@ static int tcindex_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, {struct tcindex_data *p =rtnl_dereference (tp->root);struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest; pr_debug("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n",
@@ -543,7 +542,7 @@ static int tcindex_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
Signature · 1 line
1.9.3
Quoted 13 lines · Jiri Pirko
Signed-off-by Jiri Pirko <[email protected]>--- net/sched/cls_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)net/sched/cls_basic.c +0
-0@@ -178,10 +178,9 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; }
net/sched/cls_basic.c static int basic_change(struct net *net, struct sk_buff *in_skb, · line 186
Quoted 10 lines
net/sched/cls_basic.c +2
-3- err = -ENOBUFS ; fnew =kzalloc (sizeof (*fnew),GFP_KERNEL ); -if (fnew ==NULL ) - goto errout; +if (!fnew) +return -ENOBUFS ;tcf_exts_init (&fnew->exts,TCA_BASIC_ACT ,TCA_BASIC_POLICE ); err = -EINVAL ;
Nice catch, thanks!
Signature · 1 line
John Fastabend Intel Corporation
Quoted 21 lines · John Fastabend
Quoted 20 lines · Jiri Pirko
Signed-off-by Jiri Pirko <[email protected]>--- net/sched/cls_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)net/sched/cls_basic.c +2
-3@@ -178,10 +178,9 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; } - err = -ENOBUFS ; fnew =kzalloc (sizeof (*fnew),GFP_KERNEL ); -if (fnew ==NULL ) - goto errout; +if (!fnew) +return -ENOBUFS ;
Quoted 7 lines
net/sched/cls_basic.c static int basic_change(struct net *net, struct sk_buff *in_skb, · line 186
Quoted 3 lines
net/sched/cls_basic.c +0
-0tcf_exts_init (&fnew->exts,TCA_BASIC_ACT ,TCA_BASIC_POLICE ); err = -EINVAL ;Nice catch, thanks!
Reviewed-by John Fastabend <[email protected]>
Sorry, but this looks a cosmetic change, right ?
If it is a fix, we'd like a 'Fixes: ...' tag.
Quoted 28 lines · Eric Dumazet
Quoted 27 lines · John Fastabend
Quoted 13 lines · Jiri Pirko
Signed-off-by Jiri Pirko <[email protected]>--- net/sched/cls_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)net/sched/cls_basic.c +0
-0@@ -178,10 +178,9 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; }net/sched/cls_basic.c static int basic_change(struct net *net, struct sk_buff *in_skb, · line 186
Quoted 10 lines
net/sched/cls_basic.c +2
-3- err = -ENOBUFS ; fnew =kzalloc (sizeof (*fnew),GFP_KERNEL ); -if (fnew ==NULL ) - goto errout; +if (!fnew) +return -ENOBUFS ;tcf_exts_init (&fnew->exts,TCA_BASIC_ACT ,TCA_BASIC_POLICE ); err = -EINVAL ;Nice catch, thanks!
Quoted 8 lines
Quoted 1 line
Reviewed-by John Fastabend <[email protected]>Sorry, but this looks a cosmetic change, right ?
If it is a fix, we'd like a 'Fixes: ...' tag.
oops, you are right. fnew is null, free'ing the null value is no issue at all from the error path. And if we are going to start converting the use of
if (foo == NULL) to if (!foo)
in ./net/sched that is OK but not really worth the noise in my opinion there are a lot of these in the code for quiet sometime.
Sorry for the noise. I misread it as fixing a free on some non-null value, which is not the case.
.John
Signature · 1 line
John Fastabend Intel Corporation
Hello.
Quoted 1 line · Jiri Pirko
Signed-off-by Jiri Pirko <[email protected]>
Care to explain what's wrong?
Quoted 11 lines
--- net/sched/cls_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)net/sched/cls_basic.c +0
-0@@ -178,10 +178,9 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; }
net/sched/cls_basic.c static int basic_change(struct net *net, struct sk_buff *in_skb, · line 186
Quoted 10 lines
net/sched/cls_basic.c +2
-3- err = -ENOBUFS ; fnew =kzalloc (sizeof (*fnew),GFP_KERNEL ); -if (fnew ==NULL ) - goto errout; +if (!fnew) +return -ENOBUFS ;tcf_exts_init (&fnew->exts,TCA_BASIC_ACT ,TCA_BASIC_POLICE ); err = -EINVAL ;
WBR, Sergei
Jiri Pirko
maintainerQuoted 28 lines · Fri, Dec 05, 2014 at 05:03:51PM CET, [email protected] wrote:
Quoted 27 lines · John Fastabend
Quoted 13 lines · Jiri Pirko
Signed-off-by Jiri Pirko <[email protected]>--- net/sched/cls_basic.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)net/sched/cls_basic.c +0
-0@@ -178,10 +178,9 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,return -EINVAL ; }net/sched/cls_basic.c static int basic_change(struct net *net, struct sk_buff *in_skb, · line 186
Quoted 10 lines
net/sched/cls_basic.c +2
-3- err = -ENOBUFS ; fnew =kzalloc (sizeof (*fnew),GFP_KERNEL ); -if (fnew ==NULL ) - goto errout; +if (!fnew) +return -ENOBUFS ;tcf_exts_init (&fnew->exts,TCA_BASIC_ACT ,TCA_BASIC_POLICE ); err = -EINVAL ;Nice catch, thanks!
Quoted 5 lines
Quoted 1 line
Reviewed-by John Fastabend <[email protected]>Sorry, but this looks a cosmetic change, right ?
If it is a fix, we'd like a 'Fixes: ...' tag.
Yep, cosmetic, no need to go to kfree in case kzalloc fails.
From: Jiri Pirko <[email protected]>
Date: Fri, 5 Dec 2014 15:50:22 +0100
Quoted 1 line
Signed-off-by Jiri Pirko <[email protected]>
Applied.
Re: [patch net-next 2/2] net: sched: cls: use nla_nest_cancel instead of nlmsg_trim
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Date: Fri, 5 Dec 2014 15:50:23 +0100
Quoted 3 lines
To cancel nesting, this function is more convenient.
Signed-off-by Jiri Pirko <[email protected]>
Applied.
David Miller
maintainerRe: [patch net-next 2/2] net: sched: cls: use nla_nest_cancel instead of nlmsg_trim
From: David Miller <[email protected]>
Date: Tue, 09 Dec 2014 15:42:18 -0500 (EST)
Quoted 8 lines
From: Jiri Pirko <[email protected]>
Date: Fri, 5 Dec 2014 15:50:23 +0100Quoted 3 lines
To cancel nesting, this function is more convenient.
Signed-off-by Jiri Pirko <[email protected]>Applied.
This doesn't even compile, when you took away the local 'b' variable it is still referenced by pr_debug() calls.
Jiri Pirko
maintainerPATCH v2 1/1 net: sched: cls: use nla_nest_cancel instead of nlmsg_trim
To cancel nesting, this function is more convenient.
---v1->v2:
- removed remaining use of b in tcindex pointed out by DaveM
--- net/sched/cls_cgroup.c | 3 +-- net/sched/cls_flow.c | 2 +- net/sched/cls_fw.c | 3 +-- net/sched/cls_route.c | 3 +-- net/sched/cls_rsvp.h | 3 +-- net/sched/cls_tcindex.c | 7 +++---- 6 files changed, 8 insertions(+), 13 deletions(-)
net/sched/cls_cgroup.c +1 -2
@@ -177,7 +177,6 @@ static int cls_cgroup_dump(struct net *net, struct tcf_proto *tp, unsigned long struct sk_buff *skb, struct tcmsg *t) { struct cls_cgroup_head *head = rtnl_dereference(tp->root); -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest; t->tcm_handle = head->handle;
@@ -198,7 +197,7 @@ static int cls_cgroup_dump(struct net *net, struct tcf_proto *tp, unsigned longreturn skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_flow.c +1 -1
@@ -638,7 +638,7 @@ static int flow_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, nest); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_fw.c +1 -2
@@ -356,7 +356,6 @@ static int fw_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, {struct fw_head *head =rtnl_dereference (tp->root);struct fw_filter *f = (struct fw_filter *)fh; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest;if (f ==NULL )
@@ -397,7 +396,7 @@ static int fw_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_route.c +1 -2
@@ -593,7 +593,6 @@ static int route4_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, struct sk_buff *skb, struct tcmsg *t) { struct route4_filter *f = (struct route4_filter *)fh; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest;u32 id;
@@ -635,7 +634,7 @@ static int route4_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_rsvp.h +1 -2
@@ -653,7 +653,6 @@ static int rsvp_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, {struct rsvp_filter *f = (struct rsvp_filter *)fh;struct rsvp_session *s; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest;struct tc_rsvp_pinfo pinfo;
@@ -694,7 +693,7 @@ static int rsvp_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
net/sched/cls_tcindex.c +3 -4
@@ -489,11 +489,10 @@ static int tcindex_dump(struct net *net, struct tcf_proto *tp, unsigned long fh, {struct tcindex_data *p =rtnl_dereference (tp->root);struct tcindex_filter_result *r = (struct tcindex_filter_result *) fh; -unsigned char *b =skb_tail_pointer (skb);struct nlattr *nest; -pr_debug ("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p,b %p\n" , - tp, fh, skb, t, p, r, b); +pr_debug ("tcindex_dump(tp %p,fh 0x%lx,skb %p,t %p),p %p,r %p\n" , + tp, fh, skb, t, p, r);pr_debug ("p->perfect %p p->h %p\n" , p->perfect, p->h); nest =nla_nest_start (skb,TCA_OPTIONS );
@@ -543,7 +542,7 @@ static int tcindex_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,return skb->len; nla_put_failure: -nlmsg_trim (skb, b); +nla_nest_cancel (skb, nest);return -1 ; }
Signature · 1 line
1.9.3
Re: [patch net-next v2] net: sched: cls: use nla_nest_cancel instead of nlmsg_trim
From: Jiri Pirko <[email protected]>
Date: Tue, 9 Dec 2014 22:23:29 +0100
Quoted 6 lines
To cancel nesting, this function is more convenient.
Signed-off-by Jiri Pirko <[email protected]>---
v1->v2:
- removed remaining use of b in tcindex pointed out by DaveM
This one compiles! :-)
Applied, thanks.