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 26D1CC7EE2E for ; Mon, 12 Jun 2023 11:01:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237254AbjFLLBx (ORCPT ); Mon, 12 Jun 2023 07:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237156AbjFLLBa (ORCPT ); Mon, 12 Jun 2023 07:01:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3217349C0 for ; Mon, 12 Jun 2023 03:48:51 -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 dfw.source.kernel.org (Postfix) with ESMTPS id BC274624CC for ; Mon, 12 Jun 2023 10:48:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0510C433D2; Mon, 12 Jun 2023 10:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686566930; bh=Bwi/7o/WhONTVwtwXMm6UyhSxUg+/k9PibepcG+JYP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Riaa/ysSmF60OzGG6JVPncxeVNrb+qqrYWwBiGoN+xg+5He/d2m2/muo0/dCBqAou kHQV02amTO2LV5tnJqnUagZ5Fnemm1LLIa4a3ut9WI29EXNILk9tvGZcrn1UUsDLRh cXL8H6pOrCvgEfH/lUYVw2e7R2UDymeXOBn4+hL0= 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.3 057/160] net: sched: fix possible refcount leak in tc_chain_tmplt_add() Date: Mon, 12 Jun 2023 12:26:29 +0200 Message-ID: <20230612101717.629745072@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230612101715.129581706@linuxfoundation.org> References: <20230612101715.129581706@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 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 b2432ee04f319..c877a6343fd47 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -2950,6 +2950,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