rds: prevent dereference of a NULL device in rds_iw_laddr_check
authorSasha Levin <sasha.levin@oracle.com>
Sun, 30 Mar 2014 00:39:35 +0000 (20:39 -0400)
committerWilly Tarreau <w@1wt.eu>
Mon, 19 May 2014 05:54:18 +0000 (07:54 +0200)
[ Upstream commit bf39b4247b8799935ea91d90db250ab608a58e50 ]

Binding might result in a NULL device which is later dereferenced
without checking.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
net/rds/iw.c

index db224f7c2937115612f5b572725035951da56aca..bff1e4bab51b9b2c7aeea6dcd908841f7cb62ff9 100644 (file)
@@ -237,7 +237,8 @@ static int rds_iw_laddr_check(__be32 addr)
        ret = rdma_bind_addr(cm_id, (struct sockaddr *)&sin);
        /* due to this, we will claim to support IB devices unless we
           check node_type. */
-       if (ret || cm_id->device->node_type != RDMA_NODE_RNIC)
+       if (ret || !cm_id->device ||
+           cm_id->device->node_type != RDMA_NODE_RNIC)
                ret = -EADDRNOTAVAIL;
 
        rdsdebug("addr %pI4 ret %d node type %d\n",