Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1176021imj; Thu, 14 Feb 2019 02:27:10 -0800 (PST) X-Google-Smtp-Source: AHgI3Iaa4qlcqwnGvjgPWkhqXv8qNPHCeRtu31JMtjWMQzVjlRea14aRBbCVqhr1wKxYcKh/+pJE X-Received: by 2002:a65:6658:: with SMTP id z24mr3044521pgv.189.1550140030029; Thu, 14 Feb 2019 02:27:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550140030; cv=none; d=google.com; s=arc-20160816; b=mtQml5jsGx4FgF8ilAtC/gK1nJbTt/7U4pzB21un6a/HCitN1kedTF0IJwQJq0DLR4 ulRBy/S0AlzygkdIZweYEKmrfDjQ0D0HcAZhqRdqSLEYc6WCi7wd8+Ehcq4f6z+SWMv5 ZKsmT9+T0MtIM3xd5A0PdMxxwjOmnnawtzLfY+F2pqqW4mt0iIhSht8wx6YC8d1Ggd6B CslNg4N4ApA2BYFz6+CQsvYuArSCBaNsTZ84RoOGoYTbc+otnW2YzddpotJ4rFxv9Kmo JFviWAfQNQbCvurpRy2vinkKank+u/Z0yB88bEmYY5Wl+vNRXDi5DObylJVVca6Fajmf 0k6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=2msDb181bugRk0t0BNExDIH2X3GrNZKlSI4Qtb2lgrk=; b=sHHsggdevwfCdwY8cnTGWzDcneiJuJfLTY3q+pyPV7VlenpA1xTvHnY2D4Qog66TJ8 w9kqJAew51EfcWUEg2ecHSXu1TgxMkV7PptN57bO+RKe6g8GHkXqxqRcGHR61tLUhWwO A03gSzc9bcmiS6y4wIkP89E3s1Ou0EAfsNXj1DcVSEOn908zyRUsjspOxIzRCNPfBK3B LdYGOlOSiPNboh9ql5OvtdjDVzNijeTRY+T28qqRYNhJwmzoeOWHx9iLj1pYLRToBf2u DxMLFB001zgNC6bzg5beh4oAh/T56M6RqFR5BFfpDxcps9XM3rhzYgJYnGrtHBONZ0Sp COPg== 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 w10si1929343pgj.214.2019.02.14.02.26.53; Thu, 14 Feb 2019 02:27:10 -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 S2392772AbfBNBzU (ORCPT + 99 others); Wed, 13 Feb 2019 20:55:20 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3202 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732533AbfBNBzT (ORCPT ); Wed, 13 Feb 2019 20:55:19 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5FEF880D0304659AC8D8; Thu, 14 Feb 2019 09:55:17 +0800 (CST) Received: from [10.151.23.176] (10.151.23.176) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Feb 2019 09:55:09 +0800 Subject: Re: [PATCH] erofs: fix memleak of node's shared xattr array To: Sheng Yong CC: , , , , , References: <20190214093754.14339-1-shengyong1@huawei.com> From: Gao Xiang Message-ID: <23bb86d7-817f-5447-eb2c-5e384d3a462b@huawei.com> Date: Thu, 14 Feb 2019 09:53:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20190214093754.14339-1-shengyong1@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.151.23.176] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sheng, On 2019/2/14 17:37, Sheng Yong wrote: > If it fails to read a shared xattr page, the node's shared xattr array node -> inode since erofs doesn't have 'node' concept like f2fs... > is not freed. The next time the node's xattr is accessed, the previously > allocated array is leaked. > Good catch! I think it's a valid object memory leak. the subject should be fixed as [PATCH] staging: erofs: fix memleak of inode's shared xattr array ^ Thanks, Gao Xiang > 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; >