From 83f1503f771a82af8a31f358eb825e9efb5dae6c Mon Sep 17 00:00:00 2001 From: Eric Garrido Date: Fri, 7 Aug 2015 17:38:44 -0400 Subject: [PATCH] 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 --- ssh/tcpip.go | 3 +++ 1 file changed, 3 insertions(+) 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 @@ func (c *Client) dial(laddr string, lport int, raddr string, rport int) (Channel lport: uint32(lport), } ch, in, err := c.OpenChannel("direct-tcpip", Marshal(&msg)) + if err != nil { + return nil, err + } go DiscardRequests(in) return ch, err }