From patchwork Mon Jan 18 11:35:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 366936 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47DB7C433DB for ; Mon, 18 Jan 2021 11:42:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB2C422DA9 for ; Mon, 18 Jan 2021 11:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390269AbhARLlr (ORCPT ); Mon, 18 Jan 2021 06:41:47 -0500 Received: from mail.kernel.org ([198.145.29.99]:36544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390640AbhARLkt (ORCPT ); Mon, 18 Jan 2021 06:40:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 62DFB22CF6; Mon, 18 Jan 2021 11:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610970007; bh=GekihNCoOoEUzhejpjuQ3jj1f5TvQxmJ+dDFtgWv0o8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cGtVxZMiq5uSkaK3uENMwAJ+fEjwzQkRtddxIfUNfreAxLZujH7qF7LHh9V3AwoRg T6JhpwRdnWeKVArJ12w8jgRvzX1eMyc+dwfwbElt+haOB7Vm+Lq5oDtABgyKif71bK qhckC6KUYT7z3h4MLLSq91MBQWb6nRFcSnOlVppc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Florian Westphal , Pablo Neira Ayuso Subject: [PATCH 5.4 75/76] netfilter: nf_nat: Fix memleak in nf_nat_init Date: Mon, 18 Jan 2021 12:35:15 +0100 Message-Id: <20210118113344.556629108@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210118113340.984217512@linuxfoundation.org> References: <20210118113340.984217512@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dinghao Liu commit 869f4fdaf4ca7bb6e0d05caf6fa1108dddc346a7 upstream. When register_pernet_subsys() fails, nf_nat_bysource should be freed just like when nf_ct_extend_register() fails. Fixes: 1cd472bf036ca ("netfilter: nf_nat: add nat hook register functions to nf_nat") Signed-off-by: Dinghao Liu Acked-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_nat_core.c | 1 + 1 file changed, 1 insertion(+) --- a/net/netfilter/nf_nat_core.c +++ b/net/netfilter/nf_nat_core.c @@ -1174,6 +1174,7 @@ static int __init nf_nat_init(void) ret = register_pernet_subsys(&nat_net_ops); if (ret < 0) { nf_ct_extend_unregister(&nat_extend); + kvfree(nf_nat_bysource); return ret; }