Merge branch 'for-2.6.28' of git://linux-nfs.org/~bfields/linux
* 'for-2.6.28' of git://linux-nfs.org/~bfields/linux: nfsd: clean up expkey_parse error cases nfsd: Drop reference in expkey_parse error cases nfsd: Fix memory leak in nfsd_getxattr NFSD: Fix BUG during NFSD shutdown processing
This commit is contained in:
commit
33217379be
3 changed files with 19 additions and 10 deletions
|
@ -99,7 +99,7 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
|
||||||
int fsidtype;
|
int fsidtype;
|
||||||
char *ep;
|
char *ep;
|
||||||
struct svc_expkey key;
|
struct svc_expkey key;
|
||||||
struct svc_expkey *ek;
|
struct svc_expkey *ek = NULL;
|
||||||
|
|
||||||
if (mesg[mlen-1] != '\n')
|
if (mesg[mlen-1] != '\n')
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -107,7 +107,8 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
|
||||||
|
|
||||||
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
if (!buf) goto out;
|
if (!buf)
|
||||||
|
goto out;
|
||||||
|
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
|
if ((len=qword_get(&mesg, buf, PAGE_SIZE)) <= 0)
|
||||||
|
@ -151,16 +152,16 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
|
||||||
|
|
||||||
/* now we want a pathname, or empty meaning NEGATIVE */
|
/* now we want a pathname, or empty meaning NEGATIVE */
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
if ((len=qword_get(&mesg, buf, PAGE_SIZE)) < 0)
|
len = qword_get(&mesg, buf, PAGE_SIZE);
|
||||||
|
if (len < 0)
|
||||||
goto out;
|
goto out;
|
||||||
dprintk("Path seems to be <%s>\n", buf);
|
dprintk("Path seems to be <%s>\n", buf);
|
||||||
err = 0;
|
err = 0;
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
set_bit(CACHE_NEGATIVE, &key.h.flags);
|
set_bit(CACHE_NEGATIVE, &key.h.flags);
|
||||||
ek = svc_expkey_update(&key, ek);
|
ek = svc_expkey_update(&key, ek);
|
||||||
if (ek)
|
if (!ek)
|
||||||
cache_put(&ek->h, &svc_expkey_cache);
|
err = -ENOMEM;
|
||||||
else err = -ENOMEM;
|
|
||||||
} else {
|
} else {
|
||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
err = path_lookup(buf, 0, &nd);
|
err = path_lookup(buf, 0, &nd);
|
||||||
|
@ -171,14 +172,14 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
|
||||||
key.ek_path = nd.path;
|
key.ek_path = nd.path;
|
||||||
|
|
||||||
ek = svc_expkey_update(&key, ek);
|
ek = svc_expkey_update(&key, ek);
|
||||||
if (ek)
|
if (!ek)
|
||||||
cache_put(&ek->h, &svc_expkey_cache);
|
|
||||||
else
|
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
path_put(&nd.path);
|
path_put(&nd.path);
|
||||||
}
|
}
|
||||||
cache_flush();
|
cache_flush();
|
||||||
out:
|
out:
|
||||||
|
if (ek)
|
||||||
|
cache_put(&ek->h, &svc_expkey_cache);
|
||||||
if (dom)
|
if (dom)
|
||||||
auth_domain_put(dom);
|
auth_domain_put(dom);
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
|
|
|
@ -249,6 +249,10 @@ static int nfsd_init_socks(int port)
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
error = lockd_up();
|
||||||
|
if (error < 0)
|
||||||
|
return error;
|
||||||
|
|
||||||
error = svc_create_xprt(nfsd_serv, "tcp", port,
|
error = svc_create_xprt(nfsd_serv, "tcp", port,
|
||||||
SVC_SOCK_DEFAULTS);
|
SVC_SOCK_DEFAULTS);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
|
|
|
@ -410,6 +410,7 @@ out_nfserr:
|
||||||
static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf)
|
static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf)
|
||||||
{
|
{
|
||||||
ssize_t buflen;
|
ssize_t buflen;
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
buflen = vfs_getxattr(dentry, key, NULL, 0);
|
buflen = vfs_getxattr(dentry, key, NULL, 0);
|
||||||
if (buflen <= 0)
|
if (buflen <= 0)
|
||||||
|
@ -419,7 +420,10 @@ static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf)
|
||||||
if (!*buf)
|
if (!*buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
return vfs_getxattr(dentry, key, *buf, buflen);
|
ret = vfs_getxattr(dentry, key, *buf, buflen);
|
||||||
|
if (ret < 0)
|
||||||
|
kfree(*buf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue