From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74DCEC4332F for ; Mon, 3 Oct 2022 07:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbiJCHgF (ORCPT ); Mon, 3 Oct 2022 03:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231840AbiJCHel (ORCPT ); Mon, 3 Oct 2022 03:34:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B556145989; Mon, 3 Oct 2022 00:22:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3F739B80E72; Mon, 3 Oct 2022 07:20:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABAACC433D6; Mon, 3 Oct 2022 07:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781634; bh=cDa5aTyxPYuYr2/Oz0HIB/2RvObzGfKBYzBTaVPzchs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcGSlxozDoaFJ7IaXrXt/Np3BJDKgtgCXvY8h5OA40Fj//OdNGOy3T5+HCaYjKIzk KL6Ry6h4xVaMGbiiRn6tmgC7Bq6MjsfU9Tq/FI6igFT0pHYpImMPE9+okap6nFyuKc VhYEZhMC64TW8ey227RJzDdeFH/Qpqq1wVjMyylQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 57/83] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Date: Mon, 3 Oct 2022 09:11:22 +0200 Message-Id: <20221003070723.433246341@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Hangyu Hua [ Upstream commit 6e23ec0ba92d426c77a73a9ccab16346e5e0ef49 ] nf_ct_put need to be called to put the refcount got by tcf_ct_fill_params to avoid possible refcount leak when tcf_ct_flow_table_get fails. Fixes: c34b961a2492 ("net/sched: act_ct: Create nf flow table per zone") Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220923020046.8021-1-hbh25y@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/act_ct.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c index f4fd584fba08..d85fdefe5730 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1306,7 +1306,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, err = tcf_ct_flow_table_get(params); if (err) - goto cleanup; + goto cleanup_params; spin_lock_bh(&c->tcf_lock); goto_ch = tcf_action_set_ctrlact(*a, parm->action, goto_ch); @@ -1321,6 +1321,9 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, return res; +cleanup_params: + if (params->tmpl) + nf_ct_put(params->tmpl); cleanup: if (goto_ch) tcf_chain_put_by_act(goto_ch); -- 2.35.1