]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nfsd/export.c
nfsd: clean up expkey_parse error cases
[linux-2.6-omap-h63xx.git] / fs / nfsd / export.c
index 4a85b40eef4fea0d9f74b552695b6ecabca6a547..5cd882b8871aea82445291e15db6769d7c3ee27c 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/lockd/bind.h>
 #include <linux/sunrpc/msg_prot.h>
 #include <linux/sunrpc/gss_api.h>
+#include <net/ipv6.h>
 
 #define NFSDDBG_FACILITY       NFSDDBG_EXPORT
 
@@ -98,7 +99,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
        int fsidtype;
        char *ep;
        struct svc_expkey key;
-       struct svc_expkey *ek;
+       struct svc_expkey *ek = NULL;
 
        if (mesg[mlen-1] != '\n')
                return -EINVAL;
@@ -106,7 +107,8 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 
        buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
        err = -ENOMEM;
-       if (!buf) goto out;
+       if (!buf)
+               goto out;
 
        err = -EINVAL;
        if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
@@ -150,16 +152,16 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
 
        /* now we want a pathname, or empty meaning NEGATIVE  */
        err = -EINVAL;
-       if ((len=qword_get(&mesg, buf, PAGE_SIZE)) < 0)
+       len = qword_get(&mesg, buf, PAGE_SIZE);
+       if (len < 0)
                goto out;
        dprintk("Path seems to be <%s>\n", buf);
        err = 0;
        if (len == 0) {
                set_bit(CACHE_NEGATIVE, &key.h.flags);
                ek = svc_expkey_update(&key, ek);
-               if (ek)
-                       cache_put(&ek->h, &svc_expkey_cache);
-               else err = -ENOMEM;
+               if (!ek)
+                       err = -ENOMEM;
        } else {
                struct nameidata nd;
                err = path_lookup(buf, 0, &nd);
@@ -170,14 +172,14 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
                key.ek_path = nd.path;
 
                ek = svc_expkey_update(&key, ek);
-               if (ek)
-                       cache_put(&ek->h, &svc_expkey_cache);
-               else
+               if (!ek)
                        err = -ENOMEM;
                path_put(&nd.path);
        }
        cache_flush();
  out:
+       if (ek)
+               cache_put(&ek->h, &svc_expkey_cache);
        if (dom)
                auth_domain_put(dom);
        kfree(buf);
@@ -345,7 +347,7 @@ static void svc_export_request(struct cache_detail *cd,
        char *pth;
 
        qword_add(bpp, blen, exp->ex_client->name);
-       pth = d_path(exp->ex_path.dentry, exp->ex_path.mnt, *bpp, *blen);
+       pth = d_path(&exp->ex_path, *bpp, *blen);
        if (IS_ERR(pth)) {
                /* is this correct? */
                (*bpp)[0] = '\n';
@@ -1022,7 +1024,7 @@ exp_export(struct nfsctl_export *nxp)
        /* Look up the dentry */
        err = path_lookup(nxp->ex_path, 0, &nd);
        if (err)
-               goto out_unlock;
+               goto out_put_clp;
        err = -EINVAL;
 
        exp = exp_get_by_name(clp, nd.path.mnt, nd.path.dentry, NULL);
@@ -1089,9 +1091,9 @@ finish:
                exp_put(exp);
        if (fsid_key && !IS_ERR(fsid_key))
                cache_put(&fsid_key->h, &svc_expkey_cache);
-       if (clp)
-               auth_domain_put(clp);
        path_put(&nd.path);
+out_put_clp:
+       auth_domain_put(clp);
 out_unlock:
        exp_writeunlock();
 out:
@@ -1548,6 +1550,7 @@ exp_addclient(struct nfsctl_client *ncp)
 {
        struct auth_domain      *dom;
        int                     i, err;
+       struct in6_addr addr6;
 
        /* First, consistency check. */
        err = -EINVAL;
@@ -1566,9 +1569,10 @@ exp_addclient(struct nfsctl_client *ncp)
                goto out_unlock;
 
        /* Insert client into hashtable. */
-       for (i = 0; i < ncp->cl_naddr; i++)
-               auth_unix_add_addr(ncp->cl_addrlist[i], dom);
-
+       for (i = 0; i < ncp->cl_naddr; i++) {
+               ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6);
+               auth_unix_add_addr(&addr6, dom);
+       }
        auth_unix_forget_old(dom);
        auth_domain_put(dom);