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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D102EC54EE9 for ; Tue, 20 Sep 2022 13:29:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230345AbiITN3F (ORCPT ); Tue, 20 Sep 2022 09:29:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbiITN3C (ORCPT ); Tue, 20 Sep 2022 09:29:02 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F2A4B497 for ; Tue, 20 Sep 2022 06:29:00 -0700 (PDT) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MX2M51rYYzMnDn; Tue, 20 Sep 2022 21:24:17 +0800 (CST) Received: from [10.67.110.112] (10.67.110.112) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 20 Sep 2022 21:28:58 +0800 Subject: Re: [PATCH] mm/secretmem: remove reduntant return value To: David Hildenbrand , CC: , , Binyi Han References: <20220920012205.246217-1-xiujianfeng@huawei.com> <3196b824-bcee-0c44-bfd3-f6cd8a1e6719@redhat.com> <7f1cfee4-c6de-ea59-0aa9-9bd55054fb22@redhat.com> From: xiujianfeng Message-ID: <0761fca9-b9f0-f3d7-0bf2-e73089db9d84@huawei.com> Date: Tue, 20 Sep 2022 21:28:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <7f1cfee4-c6de-ea59-0aa9-9bd55054fb22@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.110.112] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, 在 2022/9/20 21:22, David Hildenbrand 写道: > On 20.09.22 14:35, xiujianfeng wrote: >> Hi, >> >> 在 2022/9/20 20:10, David Hildenbrand 写道: >>> On 20.09.22 03:22, Xiu Jianfeng wrote: >>>> The return value @ret is always 0, so remove it and return 0 directly. >>>> >>>> Signed-off-by: Xiu Jianfeng >>>> --- >>>>    mm/secretmem.c | 6 ++---- >>>>    1 file changed, 2 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/mm/secretmem.c b/mm/secretmem.c >>>> index 6a44efb673b2..04c3ac9448a1 100644 >>>> --- a/mm/secretmem.c >>>> +++ b/mm/secretmem.c >>>> @@ -278,10 +278,8 @@ static struct file_system_type secretmem_fs = { >>>>    static int __init secretmem_init(void) >>>>    { >>>> -    int ret = 0; >>>> - >>>>        if (!secretmem_enable) >>>> -        return ret; >>>> +        return 0; >>>>        secretmem_mnt = kern_mount(&secretmem_fs); >>>>        if (IS_ERR(secretmem_mnt)) >>> >>> On top of which tree is that? >>> >>> 6.0-rc6 has here: >>> >>> if (IS_ERR(secretmem_mnt)) >>>       ret = PTR_ERR(secretmem_mnt); >>> >> Sorry, it's on linux-next tree, I should have used [PATCH -next]:) >> > > Maybe this change should be squashed into the patch from Binyi directly: > Looks good to me, thanks. > > commit 4eb5bbde3ccb710d3b85bfb13466612e56393369 (mm/mm-hotfixes-stable) > Author: Binyi Han > Date:   Sun Sep 4 00:46:47 2022 -0700 > >    mm: fix dereferencing possible ERR_PTR >    Smatch checker complains that 'secretmem_mnt' dereferencing possible >    ERR_PTR().  Let the function return if 'secretmem_mnt' is ERR_PTR, to >    avoid deferencing it. >    Link: https://lkml.kernel.org/r/20220904074647.GA64291@cloud-MacBookPro >    Fixes: 1507f51255c9f ("mm: introduce memfd_secret system call to > create "secret" memory areas") >    Signed-off-by: Binyi Han >    Reviewed-by: Andrew Morton >    Cc: Mike Rapoport >    Cc: Ammar Faizi >    Cc: Hagen Paul Pfeifer >    Cc: James Bottomley >    Cc: >    Signed-off-by: Andrew Morton > >