Skip to content

Commit 3c91e4b

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
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 <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent df50b5e commit 3c91e4b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fs/nfs/client.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,22 @@ static struct nfs_subversion *__find_nfs_version(unsigned int version)
8787
read_lock(&nfs_version_lock);
8888
nfs = nfs_version_mods[version];
8989
read_unlock(&nfs_version_lock);
90-
91-
if (nfs == NULL)
92-
return ERR_PTR(-EPROTONOSUPPORT);
9390
return nfs;
9491
}
9592

9693
struct nfs_subversion *find_nfs_version(unsigned int version)
9794
{
9895
struct nfs_subversion *nfs = __find_nfs_version(version);
9996

100-
if (IS_ERR(nfs)) {
101-
request_module("nfsv%d", version);
97+
if (!nfs && request_module("nfsv%d", version) == 0)
10298
nfs = __find_nfs_version(version);
103-
}
10499

105-
if (!IS_ERR(nfs) && !try_module_get(nfs->owner))
100+
if (!nfs)
101+
return ERR_PTR(-EPROTONOSUPPORT);
102+
103+
if (!try_module_get(nfs->owner))
106104
return ERR_PTR(-EAGAIN);
105+
107106
return nfs;
108107
}
109108

0 commit comments

Comments
 (0)