Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp352227rwb; Thu, 22 Sep 2022 19:41:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JFOEDabbSoYAa8Yoxn3LfKqZKspMPCEXCFZ/D/3xW47zLz8Aev1GuMm7bCZlRjXqF6I/z X-Received: by 2002:a05:6402:3582:b0:451:3f7b:a7c5 with SMTP id y2-20020a056402358200b004513f7ba7c5mr6426393edc.63.1663900860555; Thu, 22 Sep 2022 19:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663900860; cv=none; d=google.com; s=arc-20160816; b=vgvWXQxWnOHq99hGMu1wc6OOgQBnWS3W2hzHkGm+WnXcC8A8QkMZQ0Jb8QToYkGsi+ q5o+ia7+4uAxMvklXSAKqxaymq/ouqXT5pAf0iM42o6jY/PnOSr3NM4GPCulrtFssHd3 5ngn/umJdkKU2XCAjqQdTQgk3o7D6sGvKUCGsKbXV9qMCfAFVbHqE3/FtlMXrxET88ZI Xzm2Mvbekw18E+rhb5N67EAzUzsUVW9o/Pym8Hla6+1g2bXErtVp8sdwuw2habDy1tB5 pqYPIqldx245MrwcFpnKN0YDmk6fnrrKsfa8HeRPAI5iWYPv97ojryYPPGmn/dRXlRBl xKPw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=bB9Tyz2MGei/rxt2bSHk0QAaaZwHT52srHDPcahTgFE=; b=YgmuL8AEQRbI+wJZTTF3Pc2h9T1uWUOs5sItskMyXGYgoFoWehO4+faax9LvZCEuwm ajQyo7OpvBQMaG70cTBTk0mKIyk+UDbfy3w1LilE5t7yNQh9hGpHmFsHeKNP9ZizW4RA xkP4tAogVtmRpZUrTxTxoecD4xwiUysFbEsfO0Fn9D4sOFT62UfgMy47cvc4wkXN2xTi 4JIf+vPg9+59qaitjpWMQxid8mIOzDF4ETKQJl5heAsJ1493iW2fiBlx4QZ4GfmyJpWP Lta84ZnY8ZMnAXa9DTOVSgKeIAtPM5KMPR1SWRKHfD9ALJKfR3t/lpZAI+sYa67UmPmo Wxew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g6Ko2HQJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm10-20020a170907948a00b007700c3ad033si6951772ejc.565.2022.09.22.19.40.34; Thu, 22 Sep 2022 19:41:00 -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=@gmail.com header.s=20210112 header.b=g6Ko2HQJ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbiIWCBJ (ORCPT + 99 others); Thu, 22 Sep 2022 22:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230389AbiIWCBH (ORCPT ); Thu, 22 Sep 2022 22:01:07 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D582CE62EB; Thu, 22 Sep 2022 19:01:02 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id 207so10913377pgc.7; Thu, 22 Sep 2022 19:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=bB9Tyz2MGei/rxt2bSHk0QAaaZwHT52srHDPcahTgFE=; b=g6Ko2HQJlKOW9u/0K7tR1qSeenReSxha99ver8JK4vZIauL7NTk1136eIxYpTsW6jk qyWWTyPHYqZWA3Yoqh7HulLJzZiyQkyXxNZMDl0zyA6iNxImQ5IkuzlVx0UGgJG8u+Ph 5UZlJ35XKZrkDaEfYSnrAYF95ClMxY/XwbeWsXw7rOgf+CV6OQZCwxoVfKOgv379pd4p ecEITttOiMKlszLbMqEjStDEGPDLxJl0UCCDKrJIapR1pkGuSrApBIHnhlrnaynWt3sB Q0DQktZL+PhRtPE2cIr9Gg/BGtuNK11xodsj2zob6y6XJXEV4+NOtj733FNh6TLJqkgB Sxlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=bB9Tyz2MGei/rxt2bSHk0QAaaZwHT52srHDPcahTgFE=; b=Mcso2e2izflnjxH8PM3B/P2Pxd43S7zGxDXaoMN/X/LK7l9a4QsEn+sdztDusTlNO0 NkjX82bI9FNHI7LY3JZHqbKzVBEZTYWDrujC6d8w7HDdYJcU0mLv0o9tPiXFGnN5Fw7a OHIvjH4FVJaegUkEt2JlVIUTXWgG+kWlQOYYQ6yK0qiR4gKr0bOdUXAZFzCrfRsh6JIF kDdFDSUKhTZo0/0tV43gwVvUWHEGQAz5Uwi7cX+1OKBaq++hmPAIc5Yx36Q0khnwk9LO aD17PsWCDTJFIQVf8KFmw3XegYQSi97s8phQGL9nxSNKq32tqh+BYO5edDRRvxLA16bX C78g== X-Gm-Message-State: ACrzQf2nznHTowe/0TYHSEyuBIUbiaO0EIYLU41Lqor9ol8BlQrSCD3L KSqRfruupBbZkAvOl3r8QlY= X-Received: by 2002:a62:4e4c:0:b0:53e:22b6:6869 with SMTP id c73-20020a624e4c000000b0053e22b66869mr6462669pfb.29.1663898462325; Thu, 22 Sep 2022 19:01:02 -0700 (PDT) Received: from hbh25y.. ([129.227.150.140]) by smtp.gmail.com with ESMTPSA id s3-20020a17090a5d0300b001fbb6d73da5sm445577pji.21.2022.09.22.19.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 19:01:01 -0700 (PDT) From: Hangyu Hua To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, paulb@mellanox.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Hangyu Hua Subject: [PATCH net v2] net: sched: act_ct: fix possible refcount leak in tcf_ct_init() Date: Fri, 23 Sep 2022 10:00:46 +0800 Message-Id: <20220923020046.8021-1-hbh25y@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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 --- v2: use a new label to put the refcount. 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 d55afb8d14be..5950974ae8f6 100644 --- a/net/sched/act_ct.c +++ b/net/sched/act_ct.c @@ -1394,7 +1394,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, err = tcf_ct_flow_table_get(net, 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); @@ -1409,6 +1409,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.34.1