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>
read_lock(&nfs_version_lock);
nfs = nfs_version_mods[version];
read_unlock(&nfs_version_lock);
-
- if (nfs == NULL)
- return ERR_PTR(-EPROTONOSUPPORT);
return nfs;
}
{
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;
}