Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp40571pxb; Mon, 13 Sep 2021 12:21:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSwVORDlj51/ngOQTVz09GmdS9Z37w0aZYqPYWM9ugFOzt0RZz9LwK99oTwYdtnM9pahos X-Received: by 2002:a92:cbc6:: with SMTP id s6mr9269835ilq.260.1631560896887; Mon, 13 Sep 2021 12:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631560896; cv=none; d=google.com; s=arc-20160816; b=nXWK1keN/ZumsOKjqbzp/jLggE/sf3wZsblFtvpVRwN3NPJo5SoMrRhoN1QfTlrLJG ilxubN9mEEy0FGVBPbLrL9eCdCTJgT9xzXMX3bPKFFH0StIQ9gfRAVJ0BNAutZlWmC5/ fJNbw/ZV/FRxc2p3XK8cl+OKnSm8OFK0jZjzOd+76kKee0o9vpB0Zl1J9LMEPbnbvduy CxJ/fAFNKLrc63zoayKjycJz/zLnnj+fSQQCQAPrI09Ko8wJ55njVLEVf3AhOFJtIRwx Tl9YNC5VvNf9s/P7+HY2pP8ajqIdf4K90W/O1b1psmZ10mOSwkJHahWou4gAWbJxBvrH YyGw== 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=R6OXLyUmPVa71yD9rK/hMvcf9PiIHQqvYSRqsA0dJrQ=; b=JdlXvDZIaWbVTOMf7VgOrtNQqMtZv4vM5MDo5ClsppKSCbnDEJVj9pZJBIJf/zIqvJ YvATVUde57PYRalnerMLipWX2qQA3pyazN3lSyaZtOGoyhd6jIAmKxlchZdd9NCr3ugH XzjMlROEDjWsPnF2RiXu++HA0+Ag/BAJxfUBqgBml/TIZCYgLIfys2h8mH+qBhl24oea CcNU3dg8vqyvoYy8CEzu66tVAFV8OtIj+DRf+F/NzPPdkwTgtwy3Jt6WeW96U7X32o5n scdHU8GB+TjraAkU6LMpXzhqXlXJzreOcpZByGVnkA5mPuc3DiMY6LE472yVZyY5caaQ nXmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WOzsFEVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si6738461ila.38.2021.09.13.12.21.23; Mon, 13 Sep 2021 12:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WOzsFEVv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S240286AbhIMN04 (ORCPT + 99 others); Mon, 13 Sep 2021 09:26:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:37818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241638AbhIMNY2 (ORCPT ); Mon, 13 Sep 2021 09:24:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 745DC61106; Mon, 13 Sep 2021 13:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539319; bh=n17HKYFjzrn4XSKPbrgytBJO2vlX44ZPTurK0So+cu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOzsFEVv6LNIfUvOkMDwTgLMAPLQYJqDai9kgpQylkdbcSz6U0G1Qgu+6kYh2rAAk alTxbDQEDSiTK15Koc3QMvLKrld0kECrOVHvFxFevzh45waffsq5ymFpaXQdT4R+iO LHl7KGieapRrA3JPd991/1Q0isH86sNTIvaQjjKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiyu Yang , Cong Wang , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 123/144] net: sched: Fix qdisc_rate_table refcount leak when get tcf_block failed Date: Mon, 13 Sep 2021 15:15:04 +0200 Message-Id: <20210913131052.044146394@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiyu Yang [ Upstream commit c66070125837900163b81a03063ddd657a7e9bfb ] 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 Reviewed-by: Cong Wang Link: https://lore.kernel.org/r/1630252681-71588-1-git-send-email-xiyuyang19@fudan.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/sch_cbq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 39b427dc7512..e5972889cd81 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -1614,7 +1614,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack); if (err) { kfree(cl); - return err; + goto failure; } if (tca[TCA_RATE]) { -- 2.30.2