Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1238754imj; Thu, 14 Feb 2019 03:28:56 -0800 (PST) X-Google-Smtp-Source: AHgI3IZHWRZC5J9FO3ASJRoV+TLRTYjiuT32adtvU8JTnIrxDOzUu/0cwR7eBrkby/t4MwuRTiAs X-Received: by 2002:a62:31c1:: with SMTP id x184mr3605760pfx.204.1550143736607; Thu, 14 Feb 2019 03:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550143736; cv=none; d=google.com; s=arc-20160816; b=PwlBZbEpjs63nKT8PK6ptDtuHKwe0A+FWh7XYzETt2BVcPmlNcB2gEaKlspIVeLHQN SgouQzB4ajggI4SHOirBL054ZmMLBZE7bc5/zm4s4n5WAsQSsrtIFbJ7oEZARWV5HGzm aoK9ibZTGpUAHYZ/YUvFb/h3iqoox+O0a71z3klzFtMndwauL0euOhlOFqWQ4D2sT4Zs 8DJPg/e2VCqHjwE6EISKJPes33klfUAqcNUg/dfSELj7zkxNoMNN0dcU2zo5vM4E/foj 5NIGxalyoHHVuDlJcOmav2n2T3M7HVPxVyGNPgMyQ1nutyq2lx4wybhtpNodQmLN7S7U aQkg== 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=cCT+vJAuLzxHUQboowvAd05gUViZ5wGFx9myRoMXg1A=; b=M43KKeyHMuClnNSTdY6TqKm0RQI6AFF5AINNA1zKU3QBWu/9LW05atAhdRlRxhRG8N Sm8Aczdqa3vRxwFPcXpG1nyJt3ZKV2g22Ok8+yI+WizhEmnZGZG7WKg1SJHmenSdlvcu PrrcJh3/bdcfznlJYtrhK53l/DaEIfYF1o1ZVnAq45N3wh+dd0KjYTOzkEST1kAWKrEb i6vNCIUmraKcMB4aeHf04wWS/P3hCJjN1LaYqr9lXAJnnbgX7xhEvQfd7pzhqP6Yom76 GBzPdjvmruToMCkEduyg7of3Bg/+w523uKHzJ+6IdJ5K6uo2LP/jqEcsDZlI2hLJ/IZw 6p6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si2153334pgd.68.2019.02.14.03.28.40; Thu, 14 Feb 2019 03:28:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729201AbfBNGsC (ORCPT + 99 others); Thu, 14 Feb 2019 01:48:02 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3723 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2437133AbfBNGsA (ORCPT ); Thu, 14 Feb 2019 01:48:00 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A1036A534DFA857B75E4; Thu, 14 Feb 2019 14:47:54 +0800 (CST) Received: from localhost.localdomain (10.108.166.34) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Thu, 14 Feb 2019 14:47:44 +0800 From: Sheng Yong To: , , CC: , , , Subject: [PATCH v2] staging: erofs: fix memleak of inode's shared xattr array Date: Thu, 14 Feb 2019 14:46:36 +0800 Message-ID: <20190214064636.30039-1-shengyong1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.108.166.34] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If it fails to read a shared xattr page, the inode's shared xattr array is not freed. The next time the inode's xattr is accessed, the previously allocated array is leaked. Signed-off-by: Sheng Yong --- v2: * s/node/inode in commit message * add prefix `staging:' to the subject --- drivers/staging/erofs/xattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/erofs/xattr.c b/drivers/staging/erofs/xattr.c index 80dca6a4adbe..e3f8b904a680 100644 --- a/drivers/staging/erofs/xattr.c +++ b/drivers/staging/erofs/xattr.c @@ -92,8 +92,11 @@ static int init_inode_xattrs(struct inode *inode) it.page = erofs_get_meta_page(sb, ++it.blkaddr, S_ISDIR(inode->i_mode)); - if (IS_ERR(it.page)) + if (IS_ERR(it.page)) { + kfree(vi->xattr_shared_xattrs); + vi->xattr_shared_xattrs = NULL; return PTR_ERR(it.page); + } it.kaddr = kmap_atomic(it.page); atomic_map = true; -- 2.17.1