[ovs-dev] net: openvswitch: fix a NULL pointer dereference

Message ID 20190315042016.3137-1-kjlu@umn.edu
State New
Headers show
Series
  • [ovs-dev] net: openvswitch: fix a NULL pointer dereference
Related show

Commit Message

Kangjie Lu March 15, 2019, 4:20 a.m.
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>
---
 net/openvswitch/datapath.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

David Miller March 16, 2019, 6:36 p.m. | #1
From: Kangjie Lu <kjlu@umn.edu>
Date: Thu, 14 Mar 2019 23:20:16 -0500

> 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>

Applied.

Patch

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 6679e96ab1dc..45d1469308b0 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -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);