Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2494615rwb; Mon, 3 Oct 2022 01:17:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4nc9/0VIbTHRwhXfZXvmtHx5sMIjnKai/VUqaaQyAlE2wRP6/SLOYw2DkL/P16bfMAKbLL X-Received: by 2002:a05:6a00:1342:b0:545:4d30:eecb with SMTP id k2-20020a056a00134200b005454d30eecbmr20971987pfu.69.1664785028378; Mon, 03 Oct 2022 01:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664785028; cv=none; d=google.com; s=arc-20160816; b=N06w9yh1nsc9/Fdl8pIEZfBjmz0uXb35m8qwAnXKRJ2cMabZCqF1rym6SIeydVHoRU CCaj/xPJlnn2Y3FuINp7zKWyX0SkL/3aa00I1uyZIC9IJ3fiROun8fNJl5QuzSIBH4Kg 7iPETNOYHPtQeuMXuLdMOsmmSKAAZIG40ohNt8cT7qBp9utBo5V8ZjGps4FK0Ee4x1Xj 1LrumVgQRXhaSRqgEC75fW0VMZhTXO3hiIBkOcy8Bb6qjk4eQ1d9R3N8npwPLLBfwAK/ 7qxkbIYPQDPvytX0BjS1/YjNcgTDRI0bNl7H0PbH4O7ackaCMYkKX4YoAY/zjRDS2eOi IC1Q== 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=oLjlA3BVWM7JCyZEH+NmS/f+H3BxaP1msjK5TwOiXRg=; b=EQJd7z0Pr3KWbOpW3q9YNKu4f1cTNucqcvZH0gV9X+ykULi/l1Wf8tjmhQfGkpipSR TTrB9Xuq0W3/6Q63d9Q/Kk9B02UxzAAlMQspgbjWZe1NxKvsOnFmBYp6bHzDnGCDioi1 n+vz9oJj/D40kT0nuX+mkASF3tzyoF/eucuqYgQfhvXza0O7+krBe7zYCwjrPVY6bgy7 3A2tiNImODus63YU7Pr8xAHinwTs/plIb3K2qZU48jca1dR9h9M93lhHO3hQWAsnxuhf a8lmIjCXKpK1Y1RmJw7rr8k3UQj0v+KEWuUgkwPtaCxU4n8k8rz5PmKPI3A0Kl09PbP/ 5irA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CkSwmDdA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a170902989000b001783d4945b9si8902423plp.602.2022.10.03.01.16.55; Mon, 03 Oct 2022 01:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CkSwmDdA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231630AbiJCHhi (ORCPT + 99 others); Mon, 3 Oct 2022 03:37:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbiJCHfu (ORCPT ); Mon, 3 Oct 2022 03:35:50 -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 764D752E5B; Mon, 3 Oct 2022 00:22:36 -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 A49B6B80E97; Mon, 3 Oct 2022 07:22:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 226BEC433C1; Mon, 3 Oct 2022 07:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781727; bh=plVRTJ6RQB2Y+VJW/WUnX3V2f6K3wgn9NwlsUDQ9SzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkSwmDdA3UUzIunDS0rbKHJ5U8TGEQH0NUQOjHf8plZOpPzKr2hr1WxhP95evXCIh 4MsI6cw7vPlzE4ymnxXFU1lLBfLQZJDND3cEDndV0RPn2KtE5Vu0IiXQ3elaQtj29K wxkwsaAvtt3EcjY2ikEMTtKYWAz3y3bptV15NDao= 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.10 42/52] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Date: Mon, 3 Oct 2022 09:11:49 +0200 Message-Id: <20221003070719.987992168@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070718.687440096@linuxfoundation.org> References: <20221003070718.687440096@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 825b3e9b55f7..f7e88d7466c3 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1293,7 +1293,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); @@ -1308,6 +1308,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