Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31434f49 authored by Peng Tao's avatar Peng Tao Committed by Trond Myklebust
Browse files

nfs: check hostname in nfs_get_client



We reference cl_hostname in many places. Add a check to make
sure it exists.

Signed-off-by: default avatarPeng Tao <tao.peng@primarydata.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent a363e32e
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -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);
	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;
	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",
	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 */
	/* see if the client already exists */
	do {
	do {
@@ -510,7 +515,7 @@ nfs_get_client(const struct nfs_client_initdata *cl_init,
	} while (!IS_ERR(new));
	} while (!IS_ERR(new));


	dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",
	dprintk("<-- nfs_get_client() Failed to find %s (%ld)\n",
		cl_init->hostname ?: "", PTR_ERR(new));
		cl_init->hostname, PTR_ERR(new));
	return new;
	return new;
}
}
EXPORT_SYMBOL_GPL(nfs_get_client);
EXPORT_SYMBOL_GPL(nfs_get_client);