Skip to content

Commit

Permalink
rbd: fix CreateSnapshot panic
Browse files Browse the repository at this point in the history
add if rbdVol != nil defer rbdVol.Destroy()

Signed-off-by: huangzy <huangzynn@outlook.com>
  • Loading branch information
huangzynn committed Jul 19, 2023
1 parent 018d113 commit 8a57f3d
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 8a57f3d

Please sign in to comment.