Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp452388ybk; Fri, 15 May 2020 05:12:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG536ka6aJefoL9FtQ+029BfKqbkiEu8bJf08QoI1QD+V9oCJj8y6tPDap1CBtJmIldyNP X-Received: by 2002:a17:906:4317:: with SMTP id j23mr2295719ejm.377.1589544751591; Fri, 15 May 2020 05:12:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589544751; cv=none; d=google.com; s=arc-20160816; b=KHdbajzKWGBXzW3OoD+F89thtRsW/zzzHMGo/HRTbRtciHPhLkG0YuqAfH8uYUc8Ni VelS31r7hwCKKYBSB3HSUfuWNAkvJEr5bzXJd3v8Jimp2gPwpvNE37O1YUC6xJ3t9UAq 0nB6tVbot98fPGmlMFDCSqeg9xrsf6ZEtqhnVyT0qSuCUPE940ALSs8cH0izLoqOZbns AzDKX58Sbi9MnUU2aXl0+w3EXEIELxBxSJjiL0+uMegKat5qD2LadwcsO4X866ZbTJbG DWo4VM3K7/NY45RR9RugWMvO1xIZ74VqOA2siLw4RbPWXA4rp/4TiabuF7Fr837PXfCy qoLQ== 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=T2zvjv0FFYPvB254nssodlLwKrooNUTLmIBhPITqjMY=; b=OdXOjU7EUB6PD52w2+Y0OjdLSfegaH+cyZRZg2Jv6XsMkZiDEMva50bkB011FXlbZ3 IMC52dsLVzpxv+a4Khks4sp/PfnrLnwRYn0BOjUvtF/GB2lSy++FHN/2ADep1ZQevH0z 2CzWPCTj7VeDB68YprgpMDsp64tS9Y4ED7aTaG0Tj4V2SOAR1y/9Fvo4gmGcfNjyDPHt ZYoudSs+uLq8S8+vJZUz/fvTpquEdjoJxFr20cT51r+LwSUi+Ntn+kK4wyT1GgPjxzKD slRzro+WL3cIDNPj8z8CidoaOUKeHOAJhXDpoq7KjycqztBjmiBvwBQmOQFdpGmigakO 5ToQ== 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 dv9si1039172ejb.127.2020.05.15.05.12.06; Fri, 15 May 2020 05:12:31 -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 S1726190AbgEOMKh (ORCPT + 99 others); Fri, 15 May 2020 08:10:37 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4789 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726062AbgEOMKh (ORCPT ); Fri, 15 May 2020 08:10:37 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E8474193311A1C622AEB; Fri, 15 May 2020 20:10:32 +0800 (CST) Received: from huawei.com (10.175.124.27) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Fri, 15 May 2020 20:10:25 +0800 From: Wu Bo To: , CC: , , , , , Subject: [PATCH] blkcg:fixes memory leaks in blkg_conf_prep() Date: Fri, 15 May 2020 20:24:03 +0800 Message-ID: <1589545443-151387-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 blkg_conf_prep(): new_blkg = blkg_alloc(pos, q, GFP_KERNEL); ... blkg = blkg_lookup_check(pos, pol, q); if (IS_ERR(blkg)) { ret = PTR_ERR(blkg); goto fail_unlock; } ... if calling blkg_lookup_check() failed, at the IS_ERR block, the new_blkg should be free before goto lable fail_unlock in blkg_conf_prep() function. Signed-off-by: Wu Bo --- 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