rbd: fixed csi-rbdplugin crashes when decoding volume ID failed

Signed-off-by: HF <crazytaxii666@gmail.com>
This commit is contained in:
HF 2023-09-04 05:27:20 -04:00 committed by mergify[bot]
parent b3ef8672a4
commit 80ad5b6b8f

View File

@ -922,7 +922,11 @@ func (cs *ControllerServer) DeleteVolume(
} }
rbdVol, err := GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets()) rbdVol, err := GenVolFromVolID(ctx, volumeID, cr, req.GetSecrets())
defer rbdVol.Destroy() defer func() {
if rbdVol != nil {
rbdVol.Destroy()
}
}()
if err != nil { if err != nil {
return cs.checkErrAndUndoReserve(ctx, err, volumeID, rbdVol, cr) return cs.checkErrAndUndoReserve(ctx, err, volumeID, rbdVol, cr)
} }