From 959dfca7e63360fcb3273bcd314613cbea5bd3fc Mon Sep 17 00:00:00 2001 From: Scott Percival Date: Tue, 22 Sep 2020 14:56:03 +0800 Subject: [PATCH] service_linux: Fix null dereference in findLBEndpointSandbox Signed-off-by: Scott Percival --- libnetwork/service_linux.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go index 02ea8ff6bc..38dfc31924 100644 --- a/libnetwork/service_linux.go +++ b/libnetwork/service_linux.go @@ -67,11 +67,12 @@ func (n *network) findLBEndpointSandbox() (*endpoint, *sandbox, error) { if !ok { return nil, nil, fmt.Errorf("Unable to get sandbox for %s(%s) in for %s", ep.Name(), ep.ID(), n.ID()) } - ep = sb.getEndpoint(ep.ID()) - if ep == nil { + var sep *endpoint + sep = sb.getEndpoint(ep.ID()) + if sep == nil { return nil, nil, fmt.Errorf("Load balancing endpoint %s(%s) removed from %s", ep.Name(), ep.ID(), n.ID()) } - return ep, sb, nil + return sep, sb, nil } // Searches the OS sandbox for the name of the endpoint interface