lkml.org 
[lkml]   [2017]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] openvswitch: add null pointer check on upcall
Date
From: Colin Ian King <colin.king@canonical.com>

upcall may be assigned a NULL pointer as genlmsg_put can potentially
return a NULL. Add a null check to avoid a null pointer dereference
on upcall.

Detected by CoverityScan, CID#728404 ("Dereference null return value")

Fixes: commit ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/openvswitch/datapath.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4d38ac044cee..e8fb3d76fa6e 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -461,6 +461,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 = -ENOBUFS;
+ goto out;
+ }
upcall->dp_ifindex = dp_ifindex;

err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb);
--
2.14.1
\
 
 \ /
  Last update: 2017-11-09 15:00    [W:0.063 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site