Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1169502imj; Thu, 14 Feb 2019 02:20:02 -0800 (PST) X-Google-Smtp-Source: AHgI3IbEAqMPNl+99AKgf3HoDwavFWeQhwk0EVWLOxSt+DrBasFtl/Zzl3jIFniY3NVaWobTE2zq X-Received: by 2002:aa7:8d57:: with SMTP id s23mr3170282pfe.237.1550139602675; Thu, 14 Feb 2019 02:20:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550139602; cv=none; d=google.com; s=arc-20160816; b=RphwryqkQrOuMjVkcN+71EzivDUuXpcfvJn2bnCUd0yL7qZS6kKWOdS/M15CC5TMcr hYRoA3lJKEq3zUFFNg48grM7KcWxsAo6ou0x3rrS74PaX+TaWpPzt5ymhVd4AEfO7Qbi XFtinV3WihKFNKdOX32r/7KABu8RdMO+XJ7+iYiwRDY1K4EdWGWlppXiD77LzeflQSRg sOA81J10iJxIg3N7Wxxis9mkYI2gct05OfwtK9fUUwUlksEWPg9tG8VXCEjhZBXb5vj2 63+SY8fKmnXl//YB8bVBKUvKUQKUQcXmlDMw9Jo8UKvoLsRzQyfYtWEw+b2xxKjaymED ozdA== 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=f4yv92ul3J5BGjS9aGkgtMbQM/H80khVKgEPd8EXDnM=; b=PlJj+hL0LfilcNLRqTLHsqj2LhVOMYuOLosZcs62KVf0dy8TCFbma2KoEz58Hvh0OB qzeKyeXd2rfwHOor4RA7ei7Qvphx8jMAof9iIamG8+yDcorkHwBHeAD+VvmUE3ZK5lfv 7sibsMzrw0hvrgalHq9c3bU0ghjZ2f2u25iIuewhsbiHkcDiW/PnzVzw+/9DWS3+uFtk HHcExEpn0ZWP8+XvWZBVKN1XbdB/Omvy+H2f2xz8fGMGdQnR+J7USADtoAdWT4a460dK R2YZKM6kx1B/KS3KfulOxQrsxYB3AziUB01MHZgaAEyHhwmgpfBlqrZ1XTT094c6KvLI qA2A== 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 s7si2008876pfe.37.2019.02.14.02.19.46; Thu, 14 Feb 2019 02:20:02 -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 S2390739AbfBNBi3 (ORCPT + 99 others); Wed, 13 Feb 2019 20:38:29 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3287 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388482AbfBNBi2 (ORCPT ); Wed, 13 Feb 2019 20:38:28 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 46306FE085D8909E1A46; Thu, 14 Feb 2019 09:38:27 +0800 (CST) Received: from localhost.localdomain (10.108.166.34) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Thu, 14 Feb 2019 09:38:20 +0800 From: Sheng Yong To: , , CC: , , , Subject: [PATCH] erofs: fix memleak of node's shared xattr array Date: Thu, 14 Feb 2019 09:37:54 +0000 Message-ID: <20190214093754.14339-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 node's shared xattr array is not freed. The next time the node's xattr is accessed, the previously allocated array is leaked. Signed-off-by: Sheng Yong --- 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