diff --git a/internal/rbd/controllerserver.go b/internal/rbd/controllerserver.go index bd00d148f6b..6283ac771c8 100644 --- a/internal/rbd/controllerserver.go +++ b/internal/rbd/controllerserver.go @@ -922,7 +922,11 @@ func (cs *ControllerServer) DeleteVolume( } rbdVol, err := GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets()) - defer rbdVol.Destroy() + defer func() { + if rbdVol != nil { + rbdVol.Destroy() + } + }() if err != nil { return cs.checkErrAndUndoReserve(ctx, err, volumeID, rbdVol, cr) }