From 62d77728829cb0a3f90fe343487f95bf0fe02ae5 Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Mon, 16 Dec 2019 17:59:17 -0800 Subject: [PATCH] Check FileInfo against nil during walk of container dir path --- pkg/volume/util/subpath/subpath_linux.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/volume/util/subpath/subpath_linux.go b/pkg/volume/util/subpath/subpath_linux.go index 7778c1af02c..0663a72c50d 100644 --- a/pkg/volume/util/subpath/subpath_linux.go +++ b/pkg/volume/util/subpath/subpath_linux.go @@ -240,7 +240,8 @@ func doCleanSubPaths(mounter mount.Interface, podDir string, volumeName string) return err } - if info.IsDir() { + // We need to check that info is not nil. This may happen when the incoming err is not nil due to stale mounts or permission errors. + if info != nil && info.IsDir() { // skip subdirs of the volume: it only matters the first level to unmount, otherwise it would try to unmount subdir of the volume return filepath.SkipDir }