Skip to content

Commit

Permalink
Avoid crash when tunnel cannot be opened
Browse files Browse the repository at this point in the history
When client.Tunnel() returns an error, then the returned
stream is invalid and must not be used.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
  • Loading branch information
jandubois committed Nov 7, 2024
1 parent 6cd896f commit 897410b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/portfwd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func HandleTCPConnection(ctx context.Context, client *guestagentclient.GuestAgen
stream, err := client.Tunnel(ctx)
if err != nil {
logrus.Errorf("could not open tcp tunnel for id: %s error:%v", id, err)
return
}

g, _ := errgroup.WithContext(ctx)
Expand Down Expand Up @@ -54,6 +55,7 @@ func HandleUDPConnection(ctx context.Context, client *guestagentclient.GuestAgen
stream, err := client.Tunnel(ctx)
if err != nil {
logrus.Errorf("could not open udp tunnel for id: %s error:%v", id, err)
return
}

g, _ := errgroup.WithContext(ctx)
Expand Down

0 comments on commit 897410b

Please sign in to comment.