aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-11-14 19:27:01 -0500
committerJ. Bruce Fields <bfields@redhat.com>2010-12-17 15:48:19 -0500
commit3942302ea9e1dffa933021b20bf1642046e7641b (patch)
treec6b878198ab33ee5893f24b7366b9c209d71a2dc /net/sunrpc
parent7c96aef75949a56ec427fc6a2522dace2af33605 (diff)
sunrpc: svc_sock_names should hold ref to socket being closed.
Currently svc_sock_names calls svc_close_xprt on a svc_sock to which it does not own a reference. As soon as svc_close_xprt sets XPT_CLOSE, the socket could be freed by a separate thread (though this is a very unlikely race). It is safer to hold a reference while calling svc_close_xprt. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/svcsock.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 07919e16be3e..52bd1130e83a 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -324,19 +324,21 @@ int svc_sock_names(struct svc_serv *serv, char *buf, const size_t buflen,
324 len = onelen; 324 len = onelen;
325 break; 325 break;
326 } 326 }
327 if (toclose && strcmp(toclose, buf + len) == 0) 327 if (toclose && strcmp(toclose, buf + len) == 0) {
328 closesk = svsk; 328 closesk = svsk;
329 else 329 svc_xprt_get(&closesk->sk_xprt);
330 } else
330 len += onelen; 331 len += onelen;
331 } 332 }
332 spin_unlock_bh(&serv->sv_lock); 333 spin_unlock_bh(&serv->sv_lock);
333 334
334 if (closesk) 335 if (closesk) {
335 /* Should unregister with portmap, but you cannot 336 /* Should unregister with portmap, but you cannot
336 * unregister just one protocol... 337 * unregister just one protocol...
337 */ 338 */
338 svc_close_xprt(&closesk->sk_xprt); 339 svc_close_xprt(&closesk->sk_xprt);
339 else if (toclose) 340 svc_xprt_put(&closesk->sk_xprt);
341 } else if (toclose)
340 return -ENOENT; 342 return -ENOENT;
341 return len; 343 return len;
342} 344}