tls: fix sw_ctx leak
authorSabrina Dubroca <sd@queasysnail.net>
Tue, 16 Jan 2018 15:04:26 +0000 (16:04 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Jan 2018 13:03:48 +0000 (14:03 +0100)
commit3a28f04bc4c20e56d75327165f2922a525225b7c
treeb5862f8c1ac04d54f8a06fc234f137f34028880e
parenta022bbe393fbe3a1f471ee94d846be03f7fe2136
tls: fix sw_ctx leak

[ Upstream commit cf6d43ef66f416282121f436ce1bee9a25199d52 ]

During setsockopt(SOL_TCP, TLS_TX), if initialization of the software
context fails in tls_set_sw_offload(), we leak sw_ctx. We also don't
reassign ctx->priv_ctx to NULL, so we can't even do another attempt to
set it up on the same socket, as it will fail with -EEXIST.

Fixes: 3c4d7559159b ('tls: kernel TLS support')
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/tls/tls_sw.c