Skip to content

Commit de8d38c

Browse files
Su Huichucklever
authored andcommitted
fs: lockd: avoid possible wrong NULL parameter
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: 77a3ef3 ("NSM: More clean up of nsm_get_handle()") Signed-off-by: Su Hui <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 7afdc0c commit de8d38c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/lockd/mon.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ static struct nsm_handle *nsm_create_handle(const struct sockaddr *sap,
276276
{
277277
struct nsm_handle *new;
278278

279+
if (!hostname)
280+
return NULL;
281+
279282
new = kzalloc(sizeof(*new) + hostname_len + 1, GFP_KERNEL);
280283
if (unlikely(new == NULL))
281284
return NULL;

0 commit comments

Comments
 (0)