crypto/ssh: Handle error in dial to avoid a goroutine leak
If the channel open request failed, a nil channel would be provided to
DiscardRequests, which would never return.
We return the error early to avoid this goroutine leak.
Change-Id: I4c0e0a7698f7623c042f2a04941b8c50e8031d33
Reviewed-on: https://go-review.googlesource.com/13390
Reviewed-by: Dave Cheney <dave@cheney.net>
diff --git a/ssh/tcpip.go b/ssh/tcpip.go
index 4ecad0b..6151241 100644
--- a/ssh/tcpip.go
+++ b/ssh/tcpip.go
@@ -355,6 +355,9 @@
lport: uint32(lport),
}
ch, in, err := c.OpenChannel("direct-tcpip", Marshal(&msg))
+ if err != nil {
+ return nil, err
+ }
go DiscardRequests(in)
return ch, err
}