Skip to contentSkip to conversation

svcsock: Add a reference to sunrpc in svc_addsock

PATCH In review Tom Tucker 3 participants 3 messages Nov 23, 2008 – Nov 24, 2008 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Tom Tucker

author
#0 lore raw

PATCH 1/1 svcsock: Add a reference to sunrpc in svc_addsock

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.

---
 net/sunrpc/svcsock.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
net/sunrpc/svcsock.c +7 -2
index 95293f5..a1951dc 100644
@@ -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;
@@ -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);
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Tom Tucker

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.

A message that is not in the archive (sent off-list or not yet received): x491vx1f8o9.fsf-RRHT56Q3PSP4kTEheFKJxxDDeQx5vsVwAInAS/Ez/[email protected]

#3 lore raw
Quoted 7 lines · Jeff Moyer
Quoted 5 lines · Tom Tucker

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.

Quoted 5 lines
Quoted 4 lines

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

Done, thanks.--b.