]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFS: Fix a potential NULL dereference in nfs_get_client()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 3 Jun 2021 12:37:53 +0000 (15:37 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jun 2021 09:59:44 +0000 (11:59 +0200)
[ Upstream commit 09226e8303beeec10f2ff844d2e46d1371dc58e0 ]

None of the callers are expecting NULL returns from nfs_get_client() so
this code will lead to an Oops.  It's better to return an error
pointer.  I expect that this is dead code so hopefully no one is
affected.

Fixes: 31434f496abb ("nfs: check hostname in nfs_get_client")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/client.c

index a05f77f9c21edcd6c65ed6f1fda8a2c50d3d70e6..af838d1ed281c0e0e51a31046587c882dbfa57c8 100644 (file)
@@ -399,7 +399,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init)
 
        if (cl_init->hostname == NULL) {
                WARN_ON(1);
-               return NULL;
+               return ERR_PTR(-EINVAL);
        }
 
        /* see if the client already exists */