RDMA/cxgb3: Handle NULL inetdev pointer in iwch_query_port()
authorSteve Wise <swise@opengridcomputing.com>
Wed, 7 Oct 2009 22:51:07 +0000 (15:51 -0700)
committerRoland Dreier <rolandd@cisco.com>
Wed, 7 Oct 2009 22:51:07 +0000 (15:51 -0700)
in_dev_get() can return NULL.  If it does, iwch_query_port() will crash.
Handle the NULL case by mapping it to port state INIT.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/cxgb3/iwch_provider.c

index 6895523779d0d5ebb9d5eeb4f58e9d5ca42a1c0c..03cfaecc3bb7f901ec0eb61e1345928ed7163f6a 100644 (file)
@@ -1199,11 +1199,14 @@ static int iwch_query_port(struct ib_device *ibdev,
                props->state = IB_PORT_DOWN;
        else {
                inetdev = in_dev_get(netdev);
-               if (inetdev->ifa_list)
-                       props->state = IB_PORT_ACTIVE;
-               else
+               if (inetdev) {
+                       if (inetdev->ifa_list)
+                               props->state = IB_PORT_ACTIVE;
+                       else
+                               props->state = IB_PORT_INIT;
+                       in_dev_put(inetdev);
+               } else
                        props->state = IB_PORT_INIT;
-               in_dev_put(inetdev);
        }
 
        props->port_cap_flags =