dpaa2-eth: fix the size of the mapped SGT buffer
[linux-2.6-microblaze.git] / net / core / rtnetlink.c
index 7d72236..bb0596c 100644 (file)
@@ -139,7 +139,7 @@ bool lockdep_rtnl_is_held(void)
 EXPORT_SYMBOL(lockdep_rtnl_is_held);
 #endif /* #ifdef CONFIG_PROVE_LOCKING */
 
-static struct rtnl_link *__rcu *rtnl_msg_handlers[RTNL_FAMILY_MAX + 1];
+static struct rtnl_link __rcu *__rcu *rtnl_msg_handlers[RTNL_FAMILY_MAX + 1];
 
 static inline int rtm_msgindex(int msgtype)
 {
@@ -157,7 +157,7 @@ static inline int rtm_msgindex(int msgtype)
 
 static struct rtnl_link *rtnl_get_link(int protocol, int msgtype)
 {
-       struct rtnl_link **tab;
+       struct rtnl_link __rcu **tab;
 
        if (protocol >= ARRAY_SIZE(rtnl_msg_handlers))
                protocol = PF_UNSPEC;
@@ -166,7 +166,7 @@ static struct rtnl_link *rtnl_get_link(int protocol, int msgtype)
        if (!tab)
                tab = rcu_dereference_rtnl(rtnl_msg_handlers[PF_UNSPEC]);
 
-       return tab[msgtype];
+       return rcu_dereference_rtnl(tab[msgtype]);
 }
 
 static int rtnl_register_internal(struct module *owner,
@@ -183,7 +183,7 @@ static int rtnl_register_internal(struct module *owner,
        msgindex = rtm_msgindex(msgtype);
 
        rtnl_lock();
-       tab = rtnl_msg_handlers[protocol];
+       tab = rtnl_dereference(rtnl_msg_handlers[protocol]);
        if (tab == NULL) {
                tab = kcalloc(RTM_NR_MSGTYPES, sizeof(void *), GFP_KERNEL);
                if (!tab)
@@ -286,7 +286,8 @@ void rtnl_register(int protocol, int msgtype,
  */
 int rtnl_unregister(int protocol, int msgtype)
 {
-       struct rtnl_link **tab, *link;
+       struct rtnl_link __rcu **tab;
+       struct rtnl_link *link;
        int msgindex;
 
        BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
@@ -299,7 +300,7 @@ int rtnl_unregister(int protocol, int msgtype)
                return -ENOENT;
        }
 
-       link = tab[msgindex];
+       link = rtnl_dereference(tab[msgindex]);
        rcu_assign_pointer(tab[msgindex], NULL);
        rtnl_unlock();
 
@@ -318,20 +319,21 @@ EXPORT_SYMBOL_GPL(rtnl_unregister);
  */
 void rtnl_unregister_all(int protocol)
 {
-       struct rtnl_link **tab, *link;
+       struct rtnl_link __rcu **tab;
+       struct rtnl_link *link;
        int msgindex;
 
        BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
 
        rtnl_lock();
-       tab = rtnl_msg_handlers[protocol];
+       tab = rtnl_dereference(rtnl_msg_handlers[protocol]);
        if (!tab) {
                rtnl_unlock();
                return;
        }
        RCU_INIT_POINTER(rtnl_msg_handlers[protocol], NULL);
        for (msgindex = 0; msgindex < RTM_NR_MSGTYPES; msgindex++) {
-               link = tab[msgindex];
+               link = rtnl_dereference(tab[msgindex]);
                if (!link)
                        continue;
 
@@ -1939,7 +1941,7 @@ static const struct rtnl_link_ops *linkinfo_to_kind_ops(const struct nlattr *nla
        if (linfo[IFLA_INFO_KIND]) {
                char kind[MODULE_NAME_LEN];
 
-               nla_strlcpy(kind, linfo[IFLA_INFO_KIND], sizeof(kind));
+               nla_strscpy(kind, linfo[IFLA_INFO_KIND], sizeof(kind));
                ops = rtnl_link_ops_get(kind);
        }
 
@@ -2953,9 +2955,9 @@ static struct net_device *rtnl_dev_get(struct net *net,
        if (!ifname) {
                ifname = buffer;
                if (ifname_attr)
-                       nla_strlcpy(ifname, ifname_attr, IFNAMSIZ);
+                       nla_strscpy(ifname, ifname_attr, IFNAMSIZ);
                else if (altifname_attr)
-                       nla_strlcpy(ifname, altifname_attr, ALTIFNAMSIZ);
+                       nla_strscpy(ifname, altifname_attr, ALTIFNAMSIZ);
                else
                        return NULL;
        }
@@ -2983,7 +2985,7 @@ static int rtnl_setlink(struct sk_buff *skb, struct nlmsghdr *nlh,
                goto errout;
 
        if (tb[IFLA_IFNAME])
-               nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
+               nla_strscpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
        else
                ifname[0] = '\0';
 
@@ -3264,7 +3266,7 @@ replay:
                return err;
 
        if (tb[IFLA_IFNAME])
-               nla_strlcpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
+               nla_strscpy(ifname, tb[IFLA_IFNAME], IFNAMSIZ);
        else
                ifname[0] = '\0';
 
@@ -3296,7 +3298,7 @@ replay:
                memset(linkinfo, 0, sizeof(linkinfo));
 
        if (linkinfo[IFLA_INFO_KIND]) {
-               nla_strlcpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind));
+               nla_strscpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind));
                ops = rtnl_link_ops_get(kind);
        } else {
                kind[0] = '\0';
@@ -3754,7 +3756,7 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
                s_idx = 1;
 
        for (idx = 1; idx <= RTNL_FAMILY_MAX; idx++) {
-               struct rtnl_link **tab;
+               struct rtnl_link __rcu **tab;
                struct rtnl_link *link;
                rtnl_dumpit_func dumpit;
 
@@ -3768,7 +3770,7 @@ static int rtnl_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
                if (!tab)
                        continue;
 
-               link = tab[type];
+               link = rcu_dereference_rtnl(tab[type]);
                if (!link)
                        continue;