nfs: check hostname in nfs_get_client
authorPeng Tao <tao.peng@primarydata.com>
Tue, 8 Jul 2014 03:45:48 +0000 (11:45 +0800)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Tue, 8 Jul 2014 18:30:03 +0000 (14:30 -0400)
We reference cl_hostname in many places. Add a check to make
sure it exists.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/client.c

index 1d09289c8f0e370dd3f45a17a7c077246b23d7da..b213ee8fb01225e5adee9d447fed6aabe91d55a8 100644 (file)
@@ -482,8 +482,13 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
        struct nfs_net *nn = net_generic(cl_init->net, nfs_net_id);
        const struct nfs_rpc_ops *rpc_ops = cl_init->nfs_mod->rpc_ops;
 
+       if (cl_init->hostname == NULL) {
+               WARN_ON(1);
+               return NULL;
+       }
+
        dprintk("--> nfs_get_client(%s,v%u)\n",
-               cl_init->hostname ?: "", rpc_ops->version);
+               cl_init->hostname, rpc_ops->version);
 
        /* see if the client already exists */
        do {
@@ -510,7 +515,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
        } while (!IS_ERR(new));
 
        dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",
-               cl_init->hostname ?: "", PTR_ERR(new));
+               cl_init->hostname, PTR_ERR(new));
        return new;
 }
 EXPORT_SYMBOL_GPL(nfs_get_client);