summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorBinyi Han <dantengknight@gmail.com>2022-09-04 00:46:47 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-10-05 10:39:39 +0200
commite858f7ac7395c6016065d2bdaba469013c3313e0 (patch)
treed38c874db924c044b35fe49fc68f208dbd03dff0 /mm
parentd75ce115625ebd09c98e2309f0643654ff9a79b0 (diff)
mm: fix dereferencing possible ERR_PTR
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>
Diffstat (limited to 'mm')
-rw-r--r--mm/secretmem.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/secretmem.c b/mm/secretmem.c
index 14f49c0aa66e..d1986ce2e7c7 100644
--- 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;