From 4983792d422b1294ea0bff956e7dc91bc3c3e11e Mon Sep 17 00:00:00 2001 From: HF Date: Mon, 4 Sep 2023 05:27:20 -0400 Subject: [PATCH] rbd: fixed csi-rbdplugin crashes when decoding volume ID failed Signed-off-by: HF --- internal/rbd/controllerserver.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) }