Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4589906pja; Thu, 21 Nov 2019 22:25:17 -0800 (PST) X-Google-Smtp-Source: APXvYqzmOKS85tvXown4mwjnaORFt6LXQNuofIbhLukcRv+Jp4zP4Ttc79GHdaAraSoimLtEf65j X-Received: by 2002:a17:906:404d:: with SMTP id y13mr20438794ejj.276.1574403917059; Thu, 21 Nov 2019 22:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574403917; cv=none; d=google.com; s=arc-20160816; b=L0rM/+W5nMmmFxHGQL8FJEiNHgQ8X0bYP1IqIOF93sIVrznE2xzK7MYAP42Mo0ee0d emuLLnPvJ4q6XYqON92oaxfLx7eSyUY9MaXCsevg32sqk1ObJgg7woHm3M9MWTfs3tqo C7PntH2zBd3CCx8wLUuv8Uy0S/LwCa90jxf0T4AAfxFleftcGL7DzCDsbz8C584sMRTF IaVnmT4cV89VVNYkr8NN7rBIzi6TVXTwWnLwv/TkepSdQpqHVye6K5D3TR2G55M6kUwY UbupXfQADQ5QxVAxU9qkHNctkBU7V6G+6d84u+BXeOzr6zig7jIacP2355p5wjsL+zwO K0Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mS3Ung7h7p2lGq+4dKKp9LPi8Ou7URj+IPU6H/TsYWI=; b=XAAKu+3qgRuS0vEBPEqPFRR0O7z9KnuhQ9aTq6VAJui89W8Fv4gM6p0GrtTedS/p5a fqfTKaZ8NWrNKxs9SAXB/4yr4unn8p1Ds1CNc6p6OZZdv5iHefEInQq/aJUfJ17oBD+3 78jeR7DnnPsHKRwuriJPoCGwQIKKt/KuQQXBEMqqRkGjpprpoNOBtJEn3uHrOLcz/JWY xKUTAFsxaR8K2QiOnhPtIm9Z7M/2uL0BlWBTFxP4eT4bNlYeNI/TpNzYUF6e/qJZvJwr r9F0c6zW0AhErMn2c2xoomQHc7aFN7HotmrqMTnQSDFJ4Fl6xkuU+C5nBSiTS3KHlcZU yX1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UE8TSRUy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si3321926ejq.218.2019.11.21.22.24.53; Thu, 21 Nov 2019 22:25:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UE8TSRUy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728580AbfKVFwe (ORCPT + 99 others); Fri, 22 Nov 2019 00:52:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:58178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727313AbfKVFw1 (ORCPT ); Fri, 22 Nov 2019 00:52:27 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E9ED20717; Fri, 22 Nov 2019 05:52:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401946; bh=LCMRf+GTA8PLWlhhQyo1kvbeft7FZQoVSPIC2iobdPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UE8TSRUy73x9bFah/5w/neBBQ4vFB4BWQ4UXOrrP4zNCElKgOJGdwUHI4s4EJWw41 UDLA/Lyt/3La3/78xhKTTTTqzH9bNsK9UFusnrjy8m4jD+uDlv3VmS8ZMMbMzjxFEs WpcYyqLJdsCNzSVbHUzmKmC2AOyqJ2kmEC+yCo4g= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Gustavo A. R. Silva" , Ying Xue , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net Subject: [PATCH AUTOSEL 4.19 170/219] tipc: fix memory leak in tipc_nl_compat_publ_dump Date: Fri, 22 Nov 2019 00:48:22 -0500 Message-Id: <20191122054911.1750-163-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gustavo A. R. Silva" [ Upstream commit f87d8ad9233f115db92c6c087d58403b0009ed36 ] There is a memory leak in case genlmsg_put fails. Fix this by freeing *args* before return. Addresses-Coverity-ID: 1476406 ("Resource leak") Fixes: 46273cf7e009 ("tipc: fix a missing check of genlmsg_put") Signed-off-by: Gustavo A. R. Silva Acked-by: Ying Xue Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/tipc/netlink_compat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index fab0384d2b4b3..b4860084a8f56 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c @@ -983,8 +983,10 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock) hdr = genlmsg_put(args, 0, 0, &tipc_genl_family, NLM_F_MULTI, TIPC_NL_PUBL_GET); - if (!hdr) + if (!hdr) { + kfree_skb(args); return -EMSGSIZE; + } nest = nla_nest_start(args, TIPC_NLA_SOCK); if (!nest) { -- 2.20.1