From e5da4ed8a486113a4b0e587a0c7843e4a9c08aac Mon Sep 17 00:00:00 2001 From: Steve Wise Date: Wed, 7 Oct 2009 15:51:07 -0700 Subject: [PATCH] RDMA/cxgb3: Handle NULL inetdev pointer in iwch_query_port() 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 Signed-off-by: Roland Dreier --- drivers/infiniband/hw/cxgb3/iwch_provider.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c index 6895523779d..03cfaecc3bb 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_provider.c +++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c @@ -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 = -- 2.39.3