Re: [PATCH] sunrpc: fix error path - actually return ERR_PTR() on error

Previous thread: [PATCH 5/6] smsc95xx: check return code from control messages by Steve Glendinning on Friday, March 12, 2010 - 6:35 am. (1 message)

Next thread: [PATCH 2/6] net: remove unused #include <linux/version.h> by Huang Weiyi on Friday, March 12, 2010 - 7:12 am. (2 messages)
From: Jani Nikula
Date: Friday, March 12, 2010 - 6:48 am

Signed-off-by: Jani Nikula &lt;ext-jani.1.nikula@nokia.com&gt;

---

NOTE: I'm afraid I'm unable to test this; please consider this more a
bug report than a complete patch.
---
 net/sunrpc/xprtsock.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 7124129..5b83ff9 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -2481,7 +2481,7 @@ static struct rpc_xprt *xs_setup_bc_tcp(struct xprt_create *args)
 	struct svc_sock *bc_sock;
 
 	if (!args-&gt;bc_xprt)
-		ERR_PTR(-EINVAL);
+		return ERR_PTR(-EINVAL);
 
 	xprt = xs_setup_xprt(args, xprt_tcp_slot_table_entries);
 	if (IS_ERR(xprt))
-- 
1.6.5.2

--

From: Tetsuo Handa
Date: Friday, March 12, 2010 - 7:14 am

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

    bc_sock = container_of(args-&gt;bc_xprt, struct svc_sock, sk_xprt);
    bc_sock-&gt;sk_bc_xprt = xprt;

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

From: Trond Myklebust
Date: Friday, March 12, 2010 - 8:09 am

Or it should just be dropped. I don't see any reason why nfsd should be
trying to set up a callback channel if it doesn't already know that it
has a socket. Returning an error value in that case would just be
papering over a design bug.

   Trond
--

From: J. Bruce Fields
Date: Friday, March 12, 2010 - 1:35 pm

Yup.  At most it could be a BUG_ON, but it's probably better just to
delete the check.

--b.
--

Previous thread: [PATCH 5/6] smsc95xx: check return code from control messages by Steve Glendinning on Friday, March 12, 2010 - 6:35 am. (1 message)

Next thread: [PATCH 2/6] net: remove unused #include <linux/version.h> by Huang Weiyi on Friday, March 12, 2010 - 7:12 am. (2 messages)