Index: sys/kern/vfs_export.c =================================================================== --- sys/kern/vfs_export.c +++ sys/kern/vfs_export.c @@ -448,44 +448,48 @@ vfs_export_lookup(struct mount *mp, struct sockaddr *nam) { struct netexport *nep; - struct netcred *np; + struct netcred *np = NULL; struct radix_node_head *rnh; struct sockaddr *saddr; nep = mp->mnt_export; if (nep == NULL) return (NULL); - np = NULL; - if (mp->mnt_flag & MNT_EXPORTED) { - /* - * Lookup in the export list first. - */ - if (nam != NULL) { - saddr = nam; - rnh = NULL; - switch (saddr->sa_family) { - case AF_INET: - rnh = nep->ne4; - break; - case AF_INET6: - rnh = nep->ne6; - break; - } - if (rnh != NULL) { - RADIX_NODE_HEAD_RLOCK(rnh); - np = (struct netcred *) - (*rnh->rnh_matchaddr)(saddr, &rnh->rh); - RADIX_NODE_HEAD_RUNLOCK(rnh); - if (np && np->netc_rnodes->rn_flags & RNF_ROOT) - np = NULL; - } - } - /* - * If no address match, use the default if it exists. - */ - if (np == NULL && mp->mnt_flag & MNT_DEFEXPORTED) - np = &nep->ne_defexported; + if ((mp->mnt_flag & MNT_EXPORTED) == 0) + return (NULL); + + /* + * If no address is provided, use the default if it exists. + */ + if (nam == NULL) { + if (mp->mnt_flag & MNT_DEFEXPORTED) + return (&nep->ne_defexported); + else + return (NULL); + } + + /* + * Lookup in the export list + */ + saddr = nam; + rnh = NULL; + switch (saddr->sa_family) { + case AF_INET: + rnh = nep->ne4; + break; + case AF_INET6: + rnh = nep->ne6; + break; } + if (rnh != NULL) { + RADIX_NODE_HEAD_RLOCK(rnh); + np = (struct netcred *) + (*rnh->rnh_matchaddr)(saddr, &rnh->rh); + RADIX_NODE_HEAD_RUNLOCK(rnh); + if (np && np->netc_rnodes->rn_flags & RNF_ROOT) + np = NULL; + } + return (np); }