[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1510744186-3667-1-git-send-email-cugyly@163.com>
Date: Wed, 15 Nov 2017 19:09:46 +0800
From: yuan linyu <cugyly@....com>
To: netdev@...r.kernel.org
Cc: "David S . Miller" <davem@...emloft.net>,
yuan linyu <Linyu.Yuan@...atel-sbell.com.cn>
Subject: [PATCH net-next] net: assign err to 0 at begin in do_setlink() function
From: yuan linyu <Linyu.Yuan@...atel-sbell.com.cn>
each netlink attribute have proper process when error happen,
when exit one attribute process, it implies that no error,
so err = 0; is useless.
assign err = 0; at beginning if all attributes not set.
v1 -> v2:
fix review comment from David, clear err before
nla_for_each_nested()
Signed-off-by: yuan linyu <Linyu.Yuan@...atel-sbell.com.cn>
---
net/core/rtnetlink.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index dabba2a..4c75e40 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2075,7 +2075,7 @@ static int do_setlink(const struct sk_buff *skb,
struct nlattr **tb, char *ifname, int status)
{
const struct net_device_ops *ops = dev->netdev_ops;
- int err;
+ int err = 0;
if (tb[IFLA_NET_NS_PID] || tb[IFLA_NET_NS_FD]) {
struct net *net = rtnl_link_get_net(dev_net(dev), tb);
@@ -2237,6 +2237,7 @@ static int do_setlink(const struct sk_buff *skb,
struct nlattr *attr;
int rem;
+ err = 0;
nla_for_each_nested(attr, tb[IFLA_VFINFO_LIST], rem) {
if (nla_type(attr) != IFLA_VF_INFO ||
nla_len(attr) < NLA_HDRLEN) {
@@ -2253,7 +2254,6 @@ static int do_setlink(const struct sk_buff *skb,
status |= DO_SETLINK_NOTIFY;
}
}
- err = 0;
if (tb[IFLA_VF_PORTS]) {
struct nlattr *port[IFLA_PORT_MAX+1];
@@ -2265,6 +2265,7 @@ static int do_setlink(const struct sk_buff *skb,
if (!ops->ndo_set_vf_port)
goto errout;
+ err = 0;
nla_for_each_nested(attr, tb[IFLA_VF_PORTS], rem) {
if (nla_type(attr) != IFLA_VF_PORT ||
nla_len(attr) < NLA_HDRLEN) {
@@ -2286,7 +2287,6 @@ static int do_setlink(const struct sk_buff *skb,
status |= DO_SETLINK_NOTIFY;
}
}
- err = 0;
if (tb[IFLA_PORT_SELF]) {
struct nlattr *port[IFLA_PORT_MAX+1];
@@ -2309,6 +2309,7 @@ static int do_setlink(const struct sk_buff *skb,
struct nlattr *af;
int rem;
+ err = 0;
nla_for_each_nested(af, tb[IFLA_AF_SPEC], rem) {
const struct rtnl_af_ops *af_ops;
@@ -2326,7 +2327,6 @@ static int do_setlink(const struct sk_buff *skb,
status |= DO_SETLINK_NOTIFY;
}
}
- err = 0;
if (tb[IFLA_PROTO_DOWN]) {
err = dev_change_proto_down(dev,
--
2.7.4
Powered by blists - more mailing lists