net: openvswitch: fix a NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Fri, 15 Mar 2019 04:20:16 +0000 (23:20 -0500)
committerDavid S. Miller <davem@davemloft.net>
Sat, 16 Mar 2019 18:35:58 +0000 (11:35 -0700)
upcall is dereferenced even when genlmsg_put fails. The fix
goto out to avoid the NULL pointer dereference in this case.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/openvswitch/datapath.c

index 6679e96..45d1469 100644 (file)
@@ -448,6 +448,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
 
        upcall = genlmsg_put(user_skb, 0, 0, &dp_packet_genl_family,
                             0, upcall_info->cmd);
+       if (!upcall) {
+               err = -EINVAL;
+               goto out;
+       }
        upcall->dp_ifindex = dp_ifindex;
 
        err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb);