Skip to content

Commit

Permalink
Add a reference to sunrpc in svc_addsock
Browse files Browse the repository at this point in the history
The svc_addsock function adds transport instances without taking a
reference on the sunrpc.ko module, however, the generic transport
destruction code drops a reference when a transport instance
is destroyed.

Add a try_module_get call to the svc_addsock function for transport
instances added by this function.

Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Tested-by: Jeff Moyer <jmoyer@redhat.com>
  • Loading branch information
Tom Tucker authored and J. Bruce Fields committed Nov 24, 2008
1 parent 2c5e761 commit 2da2c21
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,11 @@ int svc_addsock(struct svc_serv *serv,
else if (so->state > SS_UNCONNECTED)
err = -EISCONN;
else {
svsk = svc_setup_socket(serv, so, &err, SVC_SOCK_DEFAULTS);
if (!try_module_get(THIS_MODULE))
err = -ENOENT;
else
svsk = svc_setup_socket(serv, so, &err,
SVC_SOCK_DEFAULTS);
if (svsk) {
struct sockaddr_storage addr;
struct sockaddr *sin = (struct sockaddr *)&addr;
Expand All @@ -1196,7 +1200,8 @@ int svc_addsock(struct svc_serv *serv,
spin_unlock_bh(&serv->sv_lock);
svc_xprt_received(&svsk->sk_xprt);
err = 0;
}
} else
module_put(THIS_MODULE);
}
if (err) {
sockfd_put(so);
Expand Down

0 comments on commit 2da2c21

Please sign in to comment.