From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00799134A4 for ; Mon, 12 Jun 2023 10:41:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78917C433D2; Mon, 12 Jun 2023 10:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686566482; bh=nelDD/aYcP3XX6JVhlFC0HLNUY5XNg6xuDsrWKkQxP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPkbkjFTxKqUgXyBWPqFUkXbtywz8nO32UH5M0mi4nojIDjwjnuQpXf/TAosVMB3U bAAUPrEOxE/RsCFXkB344fNZsPBbZjkKCo0hXSufA0QwOnAFS4C5jAx0+8/MY9V2G5 8DtQJK7Q4K0YGIVt69SHIUzBF+iZsUtgRcMLWY7U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hangyu Hua , Larysa Zaremba , "David S. Miller" , Sasha Levin Subject: [PATCH 6.1 048/132] net: sched: fix possible refcount leak in tc_chain_tmplt_add() Date: Mon, 12 Jun 2023 12:26:22 +0200 Message-ID: <20230612101712.441435979@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230612101710.279705932@linuxfoundation.org> References: <20230612101710.279705932@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Hangyu Hua [ Upstream commit 44f8baaf230c655c249467ca415b570deca8df77 ] try_module_get will be called in tcf_proto_lookup_ops. So module_put needs to be called to drop the refcount if ops don't implement the required function. Fixes: 9f407f1768d3 ("net: sched: introduce chain templates") Signed-off-by: Hangyu Hua Reviewed-by: Larysa Zaremba Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/cls_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index b51d80a2fece3..abaf75300497d 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -2780,6 +2780,7 @@ static int tc_chain_tmplt_add(struct tcf_chain *chain, struct net *net, return PTR_ERR(ops); if (!ops->tmplt_create || !ops->tmplt_destroy || !ops->tmplt_dump) { NL_SET_ERR_MSG(extack, "Chain templates are not supported with specified classifier"); + module_put(ops->owner); return -EOPNOTSUPP; } -- 2.39.2