Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2678179ybk; Mon, 18 May 2020 05:24:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvIiqMbZLPH2lE6uqighnV6iFSlndJQIpArHcFcm6U41VwzQRJTcA3A8tq5mGEWwjI7HZ3 X-Received: by 2002:aa7:d999:: with SMTP id u25mr555901eds.339.1589804685145; Mon, 18 May 2020 05:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589804685; cv=none; d=google.com; s=arc-20160816; b=b3ICBObWXwIl/2QA5ZdRUwJHU7BTLdJsf89m2ffMsGMGM8IgNUvp/wGvdXjZsQeKjK QbZ+n5uGO4bSghQkwxM/y8OyW6HHNXrztLvhqbdqWsvDyO1/pbEPQjWfHb/Zuew7ugYN pIHQWr0fccFo523bdkP+dl6n0aj3XAWpS1GOqD9B1v+0ibBYtU+h6YCsaTildT9RAROB lgdUkD3MNqVw4o7EqaI3NbetrngnER+lmsd5QW/wokiM28VK7L8m1CbJfTvbxqIRwYu0 WaMzviW9cej0xEKpeOP0TO7u8n+U2vYIRYHmkuWRMGs9vpecY339SWp10s8tlsaJEiwQ Zfww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=clKtgpaiZKguG0lMcxDtnsBOnt8Fgqa971yvHEkJ+cg=; b=UOkvWRD68Mwi/tteO9tiM5A7aQ4AMQiKeQJUThVFiy0JGW20XSFjivCN7gIYfBovpt AkdyLPyb94nwVgPi9wpTeFkITf2sA81gL7WFWBxdWSmZ3pPceOr7S/0mWPLCJQOsHTQj MM2HGAFtRry7QarR5Nv1ZLX4oEogS95qxjmkqZQfclmX6ZjwSAuLtN/qHTbEC+sgMEMm GMw5NbNhEG+2YJFBVgqjWnsve2MilT4q35dPN2/IAzRua1AXZxHicFoYHvz0pRyu/me0 zVBs4tkMSHIbkc1krPmDjU+1PI4qyMzHRmAYlj1kidlsFVkKXJEYnLmjWzQDbpFITv0z 49OA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si6746805ejx.280.2020.05.18.05.24.21; Mon, 18 May 2020 05:24:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbgERMWo (ORCPT + 99 others); Mon, 18 May 2020 08:22:44 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4812 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726585AbgERMWo (ORCPT ); Mon, 18 May 2020 08:22:44 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C07DBD3A8A3B99E9CC35; Mon, 18 May 2020 20:22:41 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.487.0; Mon, 18 May 2020 20:22:33 +0800 From: Wu Bo To: , CC: , , , , , , Subject: [PATCH] blkcg:Fix memory leaks in blkg_conf_prep() Date: Mon, 18 May 2020 20:36:06 +0800 Message-ID: <1589805366-328489-1-git-send-email-wubo40@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wu Bo If a call of the function blkg_lookup_check() failed, we should be release the previously allocated block group before jumping to the lable 'fail_unlock' in the implementation of the function blkg_conf_prep(). Suggested-by: Markus Elfring Signed-off-by: Wu Bo --- V2: omit the source code quotation from the change description --- block/blk-cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 930212c..afeb769 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -682,6 +682,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; } -- 1.8.3.1