Skip to contentSkip to conversation

sunrpc: add missing return statement

PATCH In review Johannes Weiner 3 participants 5 messages May 4, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sunrpc: add missing return statement

f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel" introduced an error case branch that lacks an actual `return' keyword before the return value. Add it.

Cc Alexandros Batsakis <[email protected]>
---
 net/sunrpc/xprtsock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/xprtsock.c +1 -1
@@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
 	struct svc_sock *bc_sock;
 
 	if (!args->bc_xprt)
-		ERR_PTR(-EINVAL);
+		return ERR_PTR(-EINVAL);
 
 	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
 	if (IS_ERR(xprt))

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 13 lines · Johannes Weiner

f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel" introduced an error case branch that lacks an actual `return' keyword before the return value. Add it.

Cc Alexandros Batsakis <[email protected]>
---
 net/sunrpc/xprtsock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

net/sunrpc/xprtsock.c static struct rpc_xprt *xs_setup_bc_tcp( · line 2450

Quoted 8 lines
net/sunrpc/xprtsock.c +1 -1
@@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
 	struct svc_sock *bc_sock;
 
 	if (!args->bc_xprt)
-		ERR_PTR(-EINVAL);
+		return ERR_PTR(-EINVAL);
 
 	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
 	if (IS_ERR(xprt))

No. It should either be a BUG_ON(), or else be removed entirely. Returning an error value for something that is clearly a programming bug is not a particularly useful exercise...

Cheers
Trond

#2 lore raw
Quoted 20 lines · Trond Myklebust
Quoted 19 lines · Johannes Weiner

f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel" introduced an error case branch that lacks an actual `return' keyword before the return value. Add it.

Cc Alexandros Batsakis <[email protected]>
---
 net/sunrpc/xprtsock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/xprtsock.c +1 -1
@@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
 	struct svc_sock *bc_sock;
 
 	if (!args->bc_xprt)
-		ERR_PTR(-EINVAL);
+		return ERR_PTR(-EINVAL);
 
Quoted 7 lines

net/sunrpc/xprtsock.c static struct rpc_xprt *xs_setup_bc_tcp( · line 2450

Quoted 2 lines
net/sunrpc/xprtsock.c +0 -0
 	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
 	if (IS_ERR(xprt))

No. It should either be a BUG_ON(), or else be removed entirely. Returning an error value for something that is clearly a programming bug is not a particularly useful exercise...

Removing NULL check is wrong because it will NULL pointer dereference later.

Quoted 11 lines · Tetsuo Handa
Quoted 7 lines · Jani Nikula

---

NOTE: I'm afraid I'm unable to test this; please consider this more a bug report than a complete patch.
---

Indeed, it has to be "return ERR_PTR(-EINVAL);". Otherwise, it will trigger NULL pointer dereference some lines later.

Quoted 6 lines
    bc_sock = container_of(args->bc_xprt, struct svc_sock, sk_xprt);
    bc_sock->sk_bc_xprt = xprt;

This bug was introduced by f300baba5a1536070d6d77bf0c8c4ca999bb4f0f "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel" and exists in 2.6.32 and later.

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 21 lines · Tetsuo Handa
Quoted 20 lines · Trond Myklebust
Quoted 19 lines · Johannes Weiner

f300bab "nfsd41: sunrpc: add new xprt class for nfsv4.1 backchannel" introduced an error case branch that lacks an actual `return' keyword before the return value. Add it.

Cc Alexandros Batsakis <[email protected]>
---
 net/sunrpc/xprtsock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/xprtsock.c +1 -1
@@ -2444,7 +2444,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(
 	struct svc_sock *bc_sock;
 
 	if (!args->bc_xprt)
-		ERR_PTR(-EINVAL);
+		return ERR_PTR(-EINVAL);
 
Quoted 8 lines
Quoted 7 lines

net/sunrpc/xprtsock.c static struct rpc_xprt *xs_setup_bc_tcp( · line 2450

Quoted 2 lines
net/sunrpc/xprtsock.c +0 -0
 	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
 	if (IS_ERR(xprt))

No. It should either be a BUG_ON(), or else be removed entirely. Returning an error value for something that is clearly a programming bug is not a particularly useful exercise...

Removing NULL check is wrong because it will NULL pointer dereference later.

Wrong. Removing NULL check is _right_ because calling this function without setting up a back channel first is a major BUG. Returning an error value to the user is pointless, since the user has no control over this. It is entirely under control of the sunrpc developers...

Trond

#4 lore raw
Quoted 11 lines · Trond Myklebust
Quoted 5 lines
Quoted 4 lines

No. It should either be a BUG_ON(), or else be removed entirely. Returning an error value for something that is clearly a programming bug is not a particularly useful exercise...

Removing NULL check is wrong because it will NULL pointer dereference later.

Wrong. Removing NULL check is _right_ because calling this function without setting up a back channel first is a major BUG. Returning an error value to the user is pointless, since the user has no control over this. It is entirely under control of the sunrpc developers...

For security people, removing

	if (!args->bc_xprt)
		ERR_PTR(-EINVAL);

is worse and changing to

	BUG_ON(!args->bc_xprt);

is better.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html