From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Yongjun Subject: [PATCH net-next] tipc: fix error handling in tipc_udp_enable() Date: Mon, 26 Mar 2018 14:32:44 +0000 Message-ID: <1522074764-22678-1-git-send-email-weiyongjun1@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Cc: Wei Yongjun , , , To: Jon Maloy , Ying Xue Return-path: Received: from szxga04-in.huawei.com ([45.249.212.190]:6695 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751903AbeCZO1n (ORCPT ); Mon, 26 Mar 2018 10:27:43 -0400 Sender: netdev-owner@vger.kernel.org List-ID: Release alloced resource before return from the error handling case in tipc_udp_enable(), otherwise will cause memory leak. Fixes: 52dfae5c85a4 ("tipc: obtain node identity from interface by default") Signed-off-by: Wei Yongjun --- net/tipc/udp_media.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c index 2c13b18..e7d91f5 100644 --- a/net/tipc/udp_media.c +++ b/net/tipc/udp_media.c @@ -687,7 +687,8 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b, } if (!tipc_own_id(net)) { pr_warn("Failed to set node id, please configure manually\n"); - return -EINVAL; + err = -EINVAL; + goto err; } b->bcast_addr.media_id = TIPC_MEDIA_TYPE_UDP;