From 7b1cb8db0edc35406655550a95f5096fd69e7c1e Mon Sep 17 00:00:00 2001 From: Maksim An Date: Thu, 4 May 2023 13:50:48 -0700 Subject: [PATCH] fix: nil pointer deref when calling `vm.OS()` Signed-off-by: Maksim An --- internal/layers/layers.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/layers/layers.go b/internal/layers/layers.go index fd7cfa5389..5eed774857 100644 --- a/internal/layers/layers.go +++ b/internal/layers/layers.go @@ -161,13 +161,14 @@ func MountLCOWLayers(ctx context.Context, containerID string, layerFolders []str // Job container: Returns the mount path on the host as a volume guid, with the volume mounted on // the host at `volumeMountPath`. func MountWCOWLayers(ctx context.Context, containerID string, layerFolders []string, guestRoot, volumeMountPath string, vm *uvm.UtilityVM) (_ string, _ resources.ResourceCloser, err error) { + if vm == nil { + return mountWCOWHostLayers(ctx, layerFolders, volumeMountPath) + } + if vm.OS() != "windows" { return "", nil, errors.New("MountWCOWLayers should only be called for WCOW") } - if vm == nil { - return mountWCOWHostLayers(ctx, layerFolders, volumeMountPath) - } return mountWCOWIsolatedLayers(ctx, containerID, layerFolders, guestRoot, volumeMountPath, vm) }