Commit 3072f00b authored by Zilin Guan's avatar Zilin Guan Committed by Jakub Kicinski
Browse files

net/handshake: Fix memory leak in tls_handshake_accept()



In tls_handshake_accept(), a netlink message is allocated using
genlmsg_new(). In the error handling path, genlmsg_cancel() is called
to cancel the message construction, but the message itself is not freed.
This leads to a memory leak.

Fix this by calling nlmsg_free() in the error path after genlmsg_cancel()
to release the allocated memory.

Fixes: 2fd55320 ("net/handshake: Add a kernel API for requesting a TLSv1.3 handshake")
Signed-off-by: default avatarZilin Guan <zilin@seu.edu.cn>
Reviewed-by: default avatarChuck Lever <chuck.lever@oracle.com>
Link: https://patch.msgid.link/20251106144511.3859535-1-zilin@seu.edu.cn


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent ec33f2e5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -259,6 +259,7 @@ static int tls_handshake_accept(struct handshake_req *req,

out_cancel:
	genlmsg_cancel(msg, hdr);
	nlmsg_free(msg);
out:
	return ret;
}