From patchwork Tue Sep 1 15:09:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 264571 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 451E5C433E2 for ; Tue, 1 Sep 2020 16:35:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 107CB207D3 for ; Tue, 1 Sep 2020 16:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598978117; bh=5nlWCuWIm7npu4Fda4YzVL0ATK2lwj9iiU7vzapDB98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Mjj0N6OgMusuBOxPegmlpthPWbht98G8C944Mb+tBr461NWB562p2K/iLEYrUi9EA SEBGCJOR2r0ZjJTmbHuaEncz5oOeK6TWEBW10kcvADlFd7Q2A3lfHwx1b1FMLnMwLf wYRYClmU3OeOsk5zbpo35+WTvUe2NzYBz9Ovmzq8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730638AbgIAPaz (ORCPT ); Tue, 1 Sep 2020 11:30:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730112AbgIAPaz (ORCPT ); Tue, 1 Sep 2020 11:30:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44F85206EB; Tue, 1 Sep 2020 15:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974254; bh=5nlWCuWIm7npu4Fda4YzVL0ATK2lwj9iiU7vzapDB98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTMoElE6UTLnSDtbZQWx+CH3g8K/ffPDadRsKbjx1qSUq5a08QMaYjv/JDmuqpTl8 D9N0kA8WNu26evNHKeec4IJ1agogFJKKgKlV5vKOkctXY+SqpJKTjz1MeOE2fMcPDp aVRZ08/Op/U5xJtHmCx3D+1D23sZnywIiLGD/E3g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yufen Yu , Jens Axboe , Sasha Levin Subject: [PATCH 5.4 106/214] blkcg: fix memleak for iolatency Date: Tue, 1 Sep 2020 17:09:46 +0200 Message-Id: <20200901150958.067453405@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150952.963606936@linuxfoundation.org> References: <20200901150952.963606936@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yufen Yu [ Upstream commit 27029b4b18aa5d3b060f0bf2c26dae254132cfce ] Normally, blkcg_iolatency_exit() will free related memory in iolatency when cleanup queue. But if blk_throtl_init() return error and queue init fail, blkcg_iolatency_exit() will not do that for us. Then it cause memory leak. Fixes: d70675121546 ("block: introduce blk-iolatency io controller") Signed-off-by: Yufen Yu Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-cgroup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 1eb8895be4c6b..0c7addcd19859 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1219,13 +1219,15 @@ int blkcg_init_queue(struct request_queue *q) if (preloaded) radix_tree_preload_end(); - ret = blk_iolatency_init(q); + ret = blk_throtl_init(q); if (ret) goto err_destroy_all; - ret = blk_throtl_init(q); - if (ret) + ret = blk_iolatency_init(q); + if (ret) { + blk_throtl_exit(q); goto err_destroy_all; + } return 0; err_destroy_all: