Commit 5680c446 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] knfsd: Fixed handling of lockd fail when adding nfsd socket

Arrgg..  We cannot 'lockd_up' before 'svc_addsock' as we don't know the
protocol yet....  So switch it around again and save the name of the created
sockets so that it can be closed if lock_up fails.
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent cda9e0cd
...@@ -523,11 +523,11 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) ...@@ -523,11 +523,11 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size)
err = nfsd_create_serv(); err = nfsd_create_serv();
if (!err) { if (!err) {
int proto = 0; int proto = 0;
err = lockd_up(proto); err = svc_addsock(nfsd_serv, fd, buf, &proto);
if (!err) { if (err >= 0) {
err = svc_addsock(nfsd_serv, fd, buf, &proto); err = lockd_up(proto);
if (err) if (err < 0)
lockd_down(); svc_sock_names(buf+strlen(buf)+1, nfsd_serv, buf);
} }
/* Decrease the count, but don't shutdown the /* Decrease the count, but don't shutdown the
* the service * the service
...@@ -536,7 +536,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) ...@@ -536,7 +536,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size)
nfsd_serv->sv_nrthreads--; nfsd_serv->sv_nrthreads--;
unlock_kernel(); unlock_kernel();
} }
return err; return err < 0 ? err : 0;
} }
if (buf[0] == '-') { if (buf[0] == '-') {
char *toclose = kstrdup(buf+1, GFP_KERNEL); char *toclose = kstrdup(buf+1, GFP_KERNEL);
......
...@@ -492,6 +492,9 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose) ...@@ -492,6 +492,9 @@ svc_sock_names(char *buf, struct svc_serv *serv, char *toclose)
} }
spin_unlock(&serv->sv_lock); spin_unlock(&serv->sv_lock);
if (closesk) if (closesk)
/* Should unregister with portmap, but you cannot
* unregister just one protocol...
*/
svc_delete_socket(closesk); svc_delete_socket(closesk);
else if (toclose) else if (toclose)
return -ENOENT; return -ENOENT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment