linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix dereferencing possible ERR_PTR
@ 2022-09-04  7:46 Binyi Han
  2022-09-04  8:39 ` Ammar Faizi
  0 siblings, 1 reply; 2+ messages in thread
From: Binyi Han @ 2022-09-04  7:46 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, kernel-janitors

Smatch checker complains that 'secretmem_mnt' dereferencing possible
ERR_PTR().
Let the function return if 'secretmem_mnt' is ERR_PTR, to avoid
deferencing it.

Signed-off-by: Binyi Han <dantengknight@gmail.com>
---
 mm/secretmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/secretmem.c b/mm/secretmem.c
index e3e9590c6fb3..3f7154099795 100644
--- a/mm/secretmem.c
+++ b/mm/secretmem.c
@@ -285,7 +285,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;
-- 
2.25.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-04  8:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-04  7:46 [PATCH] mm: fix dereferencing possible ERR_PTR Binyi Han
2022-09-04  8:39 ` Ammar Faizi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox