From 7daf0804fce3b82ff19aa5cb0483edca403660a2 Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Tue, 5 Feb 2019 00:38:02 -0800 Subject: [PATCH] Fix potential containerd panic. Signed-off-by: Lantao Liu Signed-off-by: Michael Crosby --- process.go | 8 +++++--- task.go | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/process.go b/process.go index ff7d838cde..42f3b84a9b 100644 --- a/process.go +++ b/process.go @@ -111,9 +111,11 @@ func (p *process) Start(ctx context.Context) error { ExecID: p.id, }) if err != nil { - p.io.Cancel() - p.io.Wait() - p.io.Close() + if p.io != nil { + p.io.Cancel() + p.io.Wait() + p.io.Close() + } return errdefs.FromGRPC(err) } p.pid = r.Pid diff --git a/task.go b/task.go index 6806e11620..1fbd1cc164 100644 --- a/task.go +++ b/task.go @@ -185,8 +185,10 @@ func (t *task) Start(ctx context.Context) error { ContainerID: t.id, }) if err != nil { - t.io.Cancel() - t.io.Close() + if t.io != nil { + t.io.Cancel() + t.io.Close() + } return errdefs.FromGRPC(err) } t.pid = r.Pid