From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 288DBC4363D for ; Tue, 22 Sep 2020 05:27:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A102723A84 for ; Tue, 22 Sep 2020 05:27:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A102723A84 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E36DB6B00C2; Tue, 22 Sep 2020 01:27:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE8B66B00C3; Tue, 22 Sep 2020 01:27:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFCB86B00C4; Tue, 22 Sep 2020 01:27:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0233.hostedemail.com [216.40.44.233]) by kanga.kvack.org (Postfix) with ESMTP id B6F026B00C2 for ; Tue, 22 Sep 2020 01:27:37 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 72157181AEF09 for ; Tue, 22 Sep 2020 05:27:37 +0000 (UTC) X-FDA: 77289564954.03.patch53_231283a2714b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 525F728A4E8 for ; Tue, 22 Sep 2020 05:27:37 +0000 (UTC) X-HE-Tag: patch53_231283a2714b X-Filterd-Recvd-Size: 3093 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 05:27:35 +0000 (UTC) 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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