Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3754564pxk; Tue, 22 Sep 2020 01:27:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoNFZkPoNBx+gmAtfLny3Gnwy9ceOWILaPPENS+Y/eAPqMRnbK3nN2xYzIz6+p3TiXM8sC X-Received: by 2002:a17:906:1d08:: with SMTP id n8mr3821283ejh.236.1600763223542; Tue, 22 Sep 2020 01:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600763223; cv=none; d=google.com; s=arc-20160816; b=eiVYGlQRELOIuwB5+Ui+bGC3z+n6DHXpZO+/sINOTNIVFN7XfIoUfyoM1jzRa+s9TJ JJu7lTjNGBSiDO3m14w3IQtRlENdDD+Rp1OEUN2C6fW3tOLzUYJE6y/7CdO0TOUT2LdN biw6DrdvUaJdrPaFbgh9KFFtofyqcAml+F/EXlxOycwaePUDGrCjpPXNihJf2TyPwzmx /d3km8IiYf5A/hvsvdNeehkBOJ3IweV5BOxvp7pInWBna7CMPttiBnuZ70AY+gsJmu+D KJ/XvMZJ2MMF4g+XCyg+K5zbI51XnDDcZoXJHpKXIfUx3v1tBIhsN2Hum0b5bKWMQ1vm NeDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=6swzRPEG45Upiq2wQjHzlh/Fkh8XLp4YazXUrVeT3/w=; b=wMOrB875IyYJasG1Qo/sVdvc5YygTtrxtScQa0l0PTtv7nsf/BHA+7zb25v6WNvFCx HKwVsAqlti1kiBrW/nw/5uQ8F/tIr7a78XSmAcT2UGSQBPXFYB0s8RtY/FT94Fnx/NV1 DZE28PjI96GNsaEitdyJ1MEcmPRnGIXLqP9giO3j8cGC90w1wWsriEb/Xk4j73cgPMLz 4+7qDvjZyezkGcuTtOoy+lseJV1ou4qPnkNjvimS0h1wV5xl6StAFHfxl758Amw+A23H WXf00y7u6Xkd/X6/NF5xrSpaaZPchVZofIxK8+f7JWb30eGWMsCytpCMP/5Mh/4yNC8d fm+w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m16si9746037edr.280.2020.09.22.01.26.40; Tue, 22 Sep 2020 01:27:03 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbgIVF1b (ORCPT + 99 others); Tue, 22 Sep 2020 01:27:31 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:34599 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbgIVF1b (ORCPT ); Tue, 22 Sep 2020 01:27:31 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R811e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U9kbxxV_1600752447; Received: from B-455UMD6M-2027.local(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0U9kbxxV_1600752447) by smtp.aliyun-inc.com(127.0.0.1); Tue, 22 Sep 2020 13:27:28 +0800 Subject: Re: [PATCH] mm/shmem.c: Fix the missing unaccount on the failed path To: Hugh Dickins Cc: Andrew Morton , Al Viro , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20200920163005.97079-1-tianjia.zhang@linux.alibaba.com> From: Tianjia Zhang Message-ID: <97780c27-4e66-0dc4-c05f-36adc11234a2@linux.alibaba.com> Date: Tue, 22 Sep 2020 13:27:27 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/21/20 2:49 AM, Hugh Dickins wrote: > On Mon, 21 Sep 2020, Tianjia Zhang wrote: > >> In function __shmem_file_setup(), shmem_unacct_size() is forgotten >> on the failed path, so add it. >> >> Fixes: 93dec2da7b234 ("... and switch shmem_file_setup() to alloc_file_pseudo()") >> Cc: Al Viro >> Signed-off-by: Tianjia Zhang >> --- >> mm/shmem.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/mm/shmem.c b/mm/shmem.c >> index 8e2b35ba93ad..591410dc3541 100644 >> --- a/mm/shmem.c >> +++ b/mm/shmem.c >> @@ -4200,8 +4200,10 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l >> if (!IS_ERR(res)) >> res = alloc_file_pseudo(inode, mnt, name, O_RDWR, >> &shmem_file_operations); >> - if (IS_ERR(res)) >> + if (IS_ERR(res)) { >> iput(inode); >> + shmem_unacct_size(flags, size); >> + } >> return res; >> } >> >> -- >> 2.19.1.3.ge56e4f7 > > Looks mistaken to me. > > Is this something you noticed by source inspection, > or something you have observed in practice? > > I haven't tried exercising this path while injecting errors into > alloc_file_pseudo(); but what I'd expect to happen is that the > iput(inode), which you see already on that error path, will get > to evict the inode, which will entail calling shmem_evict_inode(), > which does that shmem_unacct_size() itself. > > Hugh > I noticed by looking at the code. you are right, I neglected this point, thanks for your explanation. Thanks, Tianjia