Blob Blame History Raw
From: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Date: Sun, 29 Aug 2021 23:58:01 +0800
Subject: net: sched: Fix qdisc_rate_table refcount leak when get tcf_block
 failed
Patch-mainline: v5.15-rc1
Git-commit: c66070125837900163b81a03063ddd657a7e9bfb
References: bsc#1056657 FATE#322189 bsc#1056653 FATE#322190 bsc#1056787

The reference counting issue happens in one exception handling path of
cbq_change_class(). When failing to get tcf_block, the function forgets
to decrease the refcount of "rtab" increased by qdisc_put_rtab(),
causing a refcount leak.

Fix this issue by jumping to "failure" label when get tcf_block failed.

Fixes: 6529eaba33f0 ("net: sched: introduce tcf block infractructure")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Link: https://lore.kernel.org/r/1630252681-71588-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 net/sched/sch_cbq.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -1625,7 +1625,7 @@ cbq_change_class(struct Qdisc *sch, u32
 	err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack);
 	if (err) {
 		kfree(cl);
-		return err;
+		goto failure;
 	}
 
 	if (tca[TCA_RATE]) {