Skip to content

Commit

Permalink
fix when rbdVol is nil, panic occurred
Browse files Browse the repository at this point in the history
Signed-off-by: huangzy <huangzynn@outlook.com>
  • Loading branch information
huangzynn committed Jul 18, 2023
1 parent 018d113 commit 024ade6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,9 @@ func (cs *ControllerServer) CreateSnapshot(

// Fetch source volume information
rbdVol, err := GenVolFromVolID(ctx, req.GetSourceVolumeId(), cr, req.GetSecrets())
defer rbdVol.Destroy()
if rbdVol != nil {
defer rbdVol.Destroy()
}
if err != nil {
switch {
case errors.Is(err, ErrImageNotFound):
Expand Down

0 comments on commit 024ade6

Please sign in to comment.