Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3866752pxb; Tue, 17 Nov 2020 05:45:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTft0On8TOuJs7Z6LbNSbFR+JjAg5+m6Rl8z+syASaWhpEarNQ1KeMoEME4yzplsBrY6GR X-Received: by 2002:a05:6402:3098:: with SMTP id de24mr20441397edb.155.1605620750721; Tue, 17 Nov 2020 05:45:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605620750; cv=none; d=google.com; s=arc-20160816; b=MXSGzfTaBU+suwph3/YF2MvhpDsUflXQsuNAV3FhVNwydoHDMx0KXZrGjLpld2GrLo b28euaDGpG7KjimuOgccN7oNHcw65iyas1hy5iPLCBXZN9dwLaATMQLsR97KQ47NxMmf JxXUmxKtZWCsiw6Jma5G2uWwS/Gl7HfKN1AEg0PAQjTOwAhkfZYWLFHrqUPuQAvF1Isk ifOQOHHCInjwaNDxIQsMzsWfzLNY8h80DTiGmYbUZllW6LOnlvuCpkNb8cNc8h3ofEQK ifj0VTT0ASPtQLcOAsoTSFfk+XnEeQVW8iDe5PehayQdAdhBIQRn37/nUf1DRcR7oVL+ WC3w== 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=H51GBGNxuf7W8xtw32OhNqqMJPY+EUZEf9vucnj/Abc=; b=SSatCqD+oElrgmFVpB2QkFgb+H8yOJ93i6HCYy8+nLyiGFtEl10UikNPQ6GqVG5Nzj oi2EUwYumFyHSU9TKAK5YERBqlX+1kHbn5ok1d1BiU/cLALE/GkJTEDIhPV328dHWhU+ FG7Bf1Q2G0mX/+u69lwyLJVEI9cDUB19g/d5pGAegBhzFQCiN/9NSPRobsaaJCjY+TiU wdJxwLoFZ/xm1EIsBwAkkl+jGaYUBbpAIPLlHGnNh4FbG0Jp80Nah5psSS8GSSCb1xlW Zinff+wAajg4oTAZg6/QfsR8aXVsZ/4h2qkyuOVFWtEDw3lS0eW/RR5giTUkHvaW0GQS 0r3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rQv+A9lr; 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 hs35si14134650ejc.312.2020.11.17.05.45.27; Tue, 17 Nov 2020 05:45:50 -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=rQv+A9lr; 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 S1733024AbgKQNoJ (ORCPT + 99 others); Tue, 17 Nov 2020 08:44:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:54488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733278AbgKQNmA (ORCPT ); Tue, 17 Nov 2020 08:42:00 -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 50408207BC; Tue, 17 Nov 2020 13:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620519; bh=HZs3sKwY3AUrQ3ZOa3njDFb0VKm4z/ujkF6WC6j/QE8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rQv+A9lrQfhqwAbm65XUPUUVQVWT6DvbYha+iUu3b9oeZ2WmHXrWkwz7P0afAT2mR sOtjkQyoe+L41dMC6ZR+v/+/0jRNU5tcQmjt2yi0Ds/wdAYQZCXIkuDzuPq/8F8Xxv mc2shWPpoVvy2V+hiJqOvOSRRd0bYSG6FDnvA8zM= 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 5.9 246/255] tipc: fix memory leak in tipc_topsrv_start() Date: Tue, 17 Nov 2020 14:06:26 +0100 Message-Id: <20201117122150.904992739@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@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 @@ -665,12 +665,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; }