RDMA/cm: Change return value from find_gid_port()
authorshefty <sean.hefty@intel.com>
Wed, 28 Nov 2012 20:39:52 +0000 (20:39 +0000)
committerRoland Dreier <roland@purestorage.com>
Thu, 29 Nov 2012 20:16:29 +0000 (12:16 -0800)
commit63f05be2c075022d1b3227037f82ad75c4d5ab1d
tree7c51a7f55a4cf0e121ce1a8f5ba6c9fe075b7686
parentf4a75d2eb7b1e2206094b901be09adb31ba63681
RDMA/cm: Change return value from find_gid_port()

Problem reported by Dan Carpenter <dan.carpenter@oracle.com>:

The patch 3c86aa70bf67: "RDMA/cm: Add RDMA CM support for IBoE
devices" from Oct 13, 2010, leads to the following warning:
net/sunrpc/xprtrdma/svc_rdma_transport.c:722 svc_rdma_create()
 error: passing non neg 1 to ERR_PTR

This bug would result in a NULL dereference.  svc_rdma_create() is
supposed to return ERR_PTRs or valid pointers, but instead it returns
ERR_PTRs, valid pointers and 1.

The call tree is:

svc_rdma_create()
   => rdma_bind_addr()
      => cma_acquire_dev()
         => find_gid_port()

rdma_bind_addr() should return a valid errno.  Fix this by having
find_gid_port() also return a valid errno.  If we can't find the
specified GID on a given port, return -EADDRNOTAVAIL, rather than
-EAGAIN, to better indicate the error.  We also drop using the
special return value of '1' and instead pass through the error
returned by the underlying verbs call.  On such errors, rather
than aborting the search,  we simply continue to check the next
device/port.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/core/cma.c