Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3851832pxb; Tue, 17 Nov 2020 05:24:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPOHESz2HXz1EpesJthjWZ8+hdr6jP/O4/COi7NcchHuYFywfOHZ9Ku2Q42sBuT883K55v X-Received: by 2002:a50:eb0a:: with SMTP id y10mr21656055edp.342.1605619453936; Tue, 17 Nov 2020 05:24:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619453; cv=none; d=google.com; s=arc-20160816; b=SzzSaNRgNwWP8GeOoN7gdGAyRQuGoxDdmRhsu+EhskTGz1tM978Y+iVFcTPkhIHDie KJdjNKwy0MMIidXaEV8mlNQpoyJ2y1w1HKjjZR7U2o7n3PXZXbwv3hkY+bXYqnQulO0i 3gFDhn5flz2x0E5t0giKA/v9WelDx76Zojz7eM1vtbQjizy0thySQgzdtTrrnfsgSWdW lRVPM7WysqHv5wICCwstP25uYwn8XryVPLoLeWOxAd0xadxYBJ7SWBLnEOM1YRXNQOTf FqD6zRtpdFTnH+AzKASN4nf3Z//GiBXeJqZdJsHTgXhNPmO6ABXLvIBquUMptOjpka/V oCYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=txZt8/Eav24tsUKMoxVTMkuIlhJhH+tixFRk1FbTuEU=; b=MWd0f3bqFhuiRDNV3rQfX89ZLF/0LMwRg8HbUX/ZM5ZrhXhuMwAiq57VrUfzQh4xP8 90ti5+pVo7ygQ4fd2dKz6NawjfYgTVzJQG53wbXZA2wN2ZtACQLGUXg2FVC5Wk/AQkHT TU2C6D9FqmwXjErPes+0G5KpX589AQaaGIUpU5I8kGteFe+IGDwU99oIgi2wHqYMo/E/ zPrO9wEkFYH29aaQHP3kO06UQ7lyz8GzOY/ldWm7BjuBVyX8+qbS+MU9mQ/Yqw8IDlNE M5fAd7fjoTIel1LaRvp795IwSJpJHGaa43fJmEhn3P+2HJ32I1Zq540Fgw3ih4DQdp8+ 9paQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gtZksDGe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co22si13637057edb.469.2020.11.17.05.23.51; Tue, 17 Nov 2020 05:24:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gtZksDGe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730309AbgKQNVw (ORCPT + 99 others); Tue, 17 Nov 2020 08:21:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:55008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730686AbgKQNV1 (ORCPT ); Tue, 17 Nov 2020 08:21:27 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F0C92221FE; Tue, 17 Nov 2020 13:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619285; bh=hxBy64WOkcWKsRbU6YVf+Px82Buu2aX919pv4bVlwlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtZksDGeFrx8GHyf9XuETbsG3HwYikEihu1gi2egeYXppvITaoDRkiONJDE7hZSgU Vi48wmUF5OjGlE+134Js4GVsRYTW/ZJ8XzqnVKGy4Ouq+008GGURHZ25UTktykAhEC Tjqrew/aL7i8JugdvKe4wNkCO9flgUiy1gYogEUc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , Jakub Kicinski Subject: [PATCH 4.19 091/101] tipc: fix memory leak in tipc_topsrv_start() Date: Tue, 17 Nov 2020 14:05:58 +0100 Message-Id: <20201117122117.568350702@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wang Hai [ Upstream commit fa6882c63621821f73cc806f291208e1c6ea6187 ] kmemleak report a memory leak as follows: unreferenced object 0xffff88810a596800 (size 512): comm "ip", pid 21558, jiffies 4297568990 (age 112.120s) hex dump (first 32 bytes): 00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N.......... ff ff ff ff ff ff ff ff 00 83 60 b0 ff ff ff ff ..........`..... backtrace: [<0000000022bbe21f>] tipc_topsrv_init_net+0x1f3/0xa70 [<00000000fe15ddf7>] ops_init+0xa8/0x3c0 [<00000000138af6f2>] setup_net+0x2de/0x7e0 [<000000008c6807a3>] copy_net_ns+0x27d/0x530 [<000000006b21adbd>] create_new_namespaces+0x382/0xa30 [<00000000bb169746>] unshare_nsproxy_namespaces+0xa1/0x1d0 [<00000000fe2e42bc>] ksys_unshare+0x39c/0x780 [<0000000009ba3b19>] __x64_sys_unshare+0x2d/0x40 [<00000000614ad866>] do_syscall_64+0x56/0xa0 [<00000000a1b5ca3c>] entry_SYSCALL_64_after_hwframe+0x44/0xa9 'srv' is malloced in tipc_topsrv_start() but not free before leaving from the error handling cases. We need to free it. Fixes: 5c45ab24ac77 ("tipc: make struct tipc_server private for server.c") Reported-by: Hulk Robot Signed-off-by: Wang Hai Link: https://lore.kernel.org/r/20201109140913.47370-1-wanghai38@huawei.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/tipc/topsrv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/tipc/topsrv.c +++ b/net/tipc/topsrv.c @@ -671,12 +671,18 @@ static int tipc_topsrv_start(struct net ret = tipc_topsrv_work_start(srv); if (ret < 0) - return ret; + goto err_start; ret = tipc_topsrv_create_listener(srv); if (ret < 0) - tipc_topsrv_work_stop(srv); + goto err_create; + return 0; + +err_create: + tipc_topsrv_work_stop(srv); +err_start: + kfree(srv); return ret; }