openvswitch: Use nla_memcpy() to memcpy() data from attributes
authorThomas Graf <tgraf@suug.ch>
Fri, 29 Mar 2013 13:46:48 +0000 (14:46 +0100)
committerJesse Gross <jesse@nicira.com>
Sat, 30 Mar 2013 00:53:46 +0000 (17:53 -0700)
Less error prone as it takes into account the length of both the
destination buffer and the source attribute and documents when
data is copied from an attribute.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Jesse Gross <jesse@nicira.com>
net/openvswitch/datapath.c
net/openvswitch/flow.c

index 5b58d163a4dc06abf4c90d17441f3a8c4d58536c..bca63c8487bb390da5db73ae7a24f59480f39678 100644 (file)
@@ -672,7 +672,7 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
                goto err;
        skb_reserve(packet, NET_IP_ALIGN);
 
-       memcpy(__skb_put(packet, len), nla_data(a[OVS_PACKET_ATTR_PACKET]), len);
+       nla_memcpy(__skb_put(packet, len), a[OVS_PACKET_ATTR_PACKET], len);
 
        skb_reset_mac_header(packet);
        eth = eth_hdr(packet);
index 332486839347c26cdf134a15278315091da85cda..cf9328be75e92a730d6d8b32a5a63510e117ee5d 100644 (file)
@@ -211,7 +211,7 @@ struct sw_flow_actions *ovs_flow_actions_alloc(const struct nlattr *actions)
                return ERR_PTR(-ENOMEM);
 
        sfa->actions_len = actions_len;
-       memcpy(sfa->actions, nla_data(actions), actions_len);
+       nla_memcpy(sfa->actions, actions, actions_len);
        return sfa;
 }