]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
enic: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Mon, 2 Apr 2012 00:22:22 +0000 (20:22 -0400)
committerJoe Jin <joe.jin@oracle.com>
Wed, 29 Aug 2012 00:22:14 +0000 (08:22 +0800)
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.

(cherry picked from commit 1a106de6e6543e7d44dbe1bc5f37a8964607dfa6)
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Joe Jin <joe.jin@oracle.com>
drivers/net/enic/enic_main.c

index 57cd7923cd7efee371d12f9219c942ff1567cbca..30791b5761396450e4ec96c5da3bb4d4687496da 100644 (file)
@@ -1196,18 +1196,16 @@ static int enic_get_vf_port(struct net_device *netdev, int vf,
        if (err)
                return err;
 
-       NLA_PUT_U16(skb, IFLA_PORT_REQUEST, pp->request);
-       NLA_PUT_U16(skb, IFLA_PORT_RESPONSE, response);
-       if (pp->set & ENIC_SET_NAME)
-               NLA_PUT(skb, IFLA_PORT_PROFILE, PORT_PROFILE_MAX,
-                       pp->name);
-       if (pp->set & ENIC_SET_INSTANCE)
-               NLA_PUT(skb, IFLA_PORT_INSTANCE_UUID, PORT_UUID_MAX,
-                       pp->instance_uuid);
-       if (pp->set & ENIC_SET_HOST)
-               NLA_PUT(skb, IFLA_PORT_HOST_UUID, PORT_UUID_MAX,
-                       pp->host_uuid);
-
+       if (nla_put_u16(skb, IFLA_PORT_REQUEST, pp->request) ||
+           nla_put_u16(skb, IFLA_PORT_RESPONSE, response) ||
+           ((pp->set & ENIC_SET_NAME) &&
+            nla_put(skb, IFLA_PORT_PROFILE, PORT_PROFILE_MAX, pp->name)) ||
+           ((pp->set & ENIC_SET_INSTANCE) &&
+            nla_put(skb, IFLA_PORT_INSTANCE_UUID, PORT_UUID_MAX,
+                    pp->instance_uuid)) ||
+           ((pp->set & ENIC_SET_HOST) &&
+            nla_put(skb, IFLA_PORT_HOST_UUID, PORT_UUID_MAX, pp->host_uuid)))
+               goto nla_put_failure;
        return 0;
 
 nla_put_failure: