diff options
author | Anna Schumaker <anna.schumaker@oracle.com> | 2024-10-01 16:33:43 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@hammerspace.com> | 2024-11-08 14:17:37 -0500 |
commit | 3c91e4b7ae902bd5c05c14ff6fe74acd0bdd237a (patch) | |
tree | 780aff70cf5397194c7d7802c85a03e21dc971fe | |
parent | df50b5ee0564412e4570abae7767d9baa5911f23 (diff) |
NFS: Clean up find_nfs_version()
It's good practice to check the return value of request_module() to see
if the module has been found. It's also a little easier to follow the
code if __find_nfs_version() doesn't attempt to convert NULL pointers
into -EPROTONOSUPPORT.
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r-- | fs/nfs/client.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 27f862490f82..4c94fe419c40 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -87,9 +87,6 @@ static struct nfs_subversion *__find_nfs_version(unsigned int version) read_lock(&nfs_version_lock); nfs = nfs_version_mods[version]; read_unlock(&nfs_version_lock); - - if (nfs == NULL) - return ERR_PTR(-EPROTONOSUPPORT); return nfs; } @@ -97,13 +94,15 @@ struct nfs_subversion *find_nfs_version(unsigned int version) { struct nfs_subversion *nfs = __find_nfs_version(version); - if (IS_ERR(nfs)) { - request_module("nfsv%d", version); + if (!nfs && request_module("nfsv%d", version) == 0) nfs = __find_nfs_version(version); - } - if (!IS_ERR(nfs) && !try_module_get(nfs->owner)) + if (!nfs) + return ERR_PTR(-EPROTONOSUPPORT); + + if (!try_module_get(nfs->owner)) return ERR_PTR(-EAGAIN); + return nfs; } |