File 0002-dpif-netlink-Fix-null-pointer.patch of Package openvswitch.11325

From 42a5cb72dade142490aa2c0a4e11cb3681288366 Mon Sep 17 00:00:00 2001
From: Matteo Croce <mcroce@redhat.com>
Date: Sat, 6 Oct 2018 18:19:55 +0200
Subject: [PATCH 2/2] dpif-netlink: Fix null pointer.

In dpif_netlink_port_add__(), socksp could be NULL, because
vport_socksp_to_pids() would allocate a new array and return a single
zero element.
Following vport_socksp_to_pids() removal, a NULL pointer can happen when
dpif_netlink_port_add__() is called and dpif->handlers is 0.

Restore the old behaviour of using a zero pid when dpif->handlers is 0.

Fixes: 69c51582f ("dpif-netlink: don't allocate per thread netlink sockets")
Reported-by: Flavio Leitner <fbl@redhat.com>
Reported-by: Guru Shetty <guru@ovn.org>
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
(cherry picked from commit 790a437229744270bebf7e707e298910e102254f)
---
 lib/dpif-netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index b97e0b5e4..e9f559b3b 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -686,7 +686,7 @@ dpif_netlink_port_add__(struct dpif_netlink *dpif, struct netdev *netdev,
     uint64_t options_stub[64 / 8];
     struct ofpbuf options;
     struct nl_sock *socksp = NULL;
-    uint32_t upcall_pids;
+    uint32_t upcall_pids = 0;
     int error = 0;
 
     if (dpif->handlers) {
@@ -740,7 +740,9 @@ dpif_netlink_port_add__(struct dpif_netlink *dpif, struct netdev *netdev,
     }
 
     request.port_no = *port_nop;
-    upcall_pids = nl_sock_pid(socksp);
+    if (socksp) {
+        upcall_pids = nl_sock_pid(socksp);
+    }
     request.n_upcall_pids = 1;
     request.upcall_pids = &upcall_pids;
 
-- 
2.19.0

openSUSE Build Service is sponsored by