lkml.org 
[lkml]   [2022]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.15 31/83] mm: fix dereferencing possible ERR_PTR
    Date
    From: Binyi Han <dantengknight@gmail.com>

    commit 4eb5bbde3ccb710d3b85bfb13466612e56393369 upstream.

    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 <dantengknight@gmail.com>
    Reviewed-by: Andrew Morton <akpm@linux-foudation.org>
    Cc: Mike Rapoport <rppt@kernel.org>
    Cc: Ammar Faizi <ammarfaizi2@gnuweeb.org>
    Cc: Hagen Paul Pfeifer <hagen@jauu.net>
    Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    mm/secretmem.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

    --- a/mm/secretmem.c
    +++ b/mm/secretmem.c
    @@ -283,7 +283,7 @@ static int secretmem_init(void)

    secretmem_mnt = kern_mount(&secretmem_fs);
    if (IS_ERR(secretmem_mnt))
    - ret = PTR_ERR(secretmem_mnt);
    + return PTR_ERR(secretmem_mnt);

    /* prevent secretmem mappings from ever getting PROT_EXEC */
    secretmem_mnt->mnt_flags |= MNT_NOEXEC;

    \
     
     \ /
      Last update: 2022-10-03 09:31    [W:3.043 / U:0.616 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site