caif: Stop using NLA_PUT*().
authorDavid S. Miller <davem@davemloft.net>
Mon, 2 Apr 2012 00:48:13 +0000 (20:48 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Apr 2012 08:33:44 +0000 (04:33 -0400)
These macros contain a hidden goto, and are thus extremely error
prone and make code hard to audit.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/caif/chnl_net.c

index 20618dd3088b79e0f1528436c7b1c9359f9c9cd6..93e9c6dc9ddfd5360d685843f0ebb271e102154a 100644 (file)
@@ -421,14 +421,14 @@ static int ipcaif_fill_info(struct sk_buff *skb, const struct net_device *dev)
        struct chnl_net *priv;
        u8 loop;
        priv = netdev_priv(dev);
-       NLA_PUT_U32(skb, IFLA_CAIF_IPV4_CONNID,
-                   priv->conn_req.sockaddr.u.dgm.connection_id);
-       NLA_PUT_U32(skb, IFLA_CAIF_IPV6_CONNID,
-                   priv->conn_req.sockaddr.u.dgm.connection_id);
+       if (nla_put_u32(skb, IFLA_CAIF_IPV4_CONNID,
+                       priv->conn_req.sockaddr.u.dgm.connection_id) ||
+           nla_put_u32(skb, IFLA_CAIF_IPV6_CONNID,
+                       priv->conn_req.sockaddr.u.dgm.connection_id))
+               goto nla_put_failure;
        loop = priv->conn_req.protocol == CAIFPROTO_DATAGRAM_LOOP;
-       NLA_PUT_U8(skb, IFLA_CAIF_LOOPBACK, loop);
-
-
+       if (nla_put_u8(skb, IFLA_CAIF_LOOPBACK, loop))
+               goto nla_put_failure;
        return 0;
 nla_put_failure:
        return -EMSGSIZE;