mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: lockd: avoid possible wrong NULL parameter
@ 2023-08-02  8:05 Su Hui
  2023-08-02 10:25 ` Dan Carpenter
  0 siblings, 1 reply; 10+ messages in thread
From: Su Hui @ 2023-08-02  8:05 UTC (permalink / raw)
  To: chuck.lever, jlayton, neilb, kolga, Dai.Ngo, tom,
	trond.myklebust, anna, nathan, ndesaulniers, trix
  Cc: bfields, linux-nfs, linux-kernel, llvm, kernel-janitors, Su Hui

clang's static analysis warning: fs/lockd/mon.c: line 293, column 2:
Null pointer passed as 2nd argument to memory copy function.

Assuming 'hostname' is NULL and calling 'nsm_create_handle()', this will
pass NULL as 2nd argument to memory copy function 'memcpy()'. So return
NULL if 'hostname' is invalid.

Fixes: 77a3ef33e2de ("NSM: More clean up of nsm_get_handle()")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 fs/lockd/mon.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 1d9488cf0534..eebab013e063 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -358,6 +358,9 @@ struct nsm_handle *nsm_get_handle(const struct net *net,
 
 	spin_unlock(&nsm_lock);
 
+	if (!hostname)
+		return NULL;
+
 	new = nsm_create_handle(sap, salen, hostname, hostname_len);
 	if (unlikely(new == NULL))
 		return NULL;
-- 
2.30.2


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

end of thread, other threads:[~2023-08-03 16:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-02  8:05 [PATCH] fs: lockd: avoid possible wrong NULL parameter Su Hui
2023-08-02 10:25 ` Dan Carpenter
2023-08-02 10:41   ` Dan Carpenter
2023-08-03  3:08     ` Su Hui
2023-08-02 21:40   ` Nick Desaulniers
2023-08-03  4:16     ` Su Hui
2023-08-03  9:10       ` Dan Carpenter
2023-08-03  9:08     ` Dan Carpenter
     [not found]     ` <5066885c-3ac9-adbd-6852-eba89657470c@nfschina.com>
2023-08-03 16:38       ` Nick Desaulniers
2023-08-03 16:56         ` Jeff Layton

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

all inboxes | Powered by JetHome®