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 X-Spam-Level: X-Spam-Status: No, score=-12.8 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=ham 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 749EFC2D0A3 for ; Mon, 9 Nov 2020 13:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ABBC2083B for ; Mon, 9 Nov 2020 13:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927410; bh=iyOK1jee0ofzuWK2iruqh5P+w/16VMaZeppQ6bw4obg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uS3VpTPc4PnfwV/SJ7RhyGwEnlAqirSH+1Q/GPLBwiOxmD8qsvj6itLrePwAC6l6y Bc4Em1dmAjq2bWeLTccumnvVDn1yYPSudukHIIin79kYQqLDbalRIye5ZRv0KnscVy be2jS6beh+d5xgszsjzM+jkW+hSIl0VUtWAabrY0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731980AbgKINKJ (ORCPT ); Mon, 9 Nov 2020 08:10:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:35248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731957AbgKINKH (ORCPT ); Mon, 9 Nov 2020 08:10:07 -0500 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 017CD20867; Mon, 9 Nov 2020 13:10:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927406; bh=iyOK1jee0ofzuWK2iruqh5P+w/16VMaZeppQ6bw4obg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=upZ4KKmFRYR5m+uqvpSXH5xiuNoQgAGHv8gUWMjNcpYhaT6c7NuNg0E3X+6lfyrsH bvyjma1tJQLowvU8VY5Dd9Pe7RJEZxo6S6o+5kbnW318qlswrGkjPqPIYfmbjLQ0me bbhF2sAd6lvCz1qNOVsapBcWnnz5977q6EFU1kj0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tejun Heo , Gabriel Krisman Bertazi , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 49/71] blk-cgroup: Fix memleak on error path Date: Mon, 9 Nov 2020 13:55:43 +0100 Message-Id: <20201109125022.204168244@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125019.906191744@linuxfoundation.org> References: <20201109125019.906191744@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: stable@vger.kernel.org From: Gabriel Krisman Bertazi [ Upstream commit 52abfcbd57eefdd54737fc8c2dc79d8f46d4a3e5 ] If new_blkg allocation raced with blk_policy change and blkg_lookup_check fails, new_blkg is leaked. Acked-by: Tejun Heo Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index a06547fe6f6b4..51fc803c999d7 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -882,6 +882,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, blkg = blkg_lookup_check(pos, pol, q); if (IS_ERR(blkg)) { ret = PTR_ERR(blkg); + blkg_free(new_blkg); goto fail_unlock; } -- 2.27.0