diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index a7d508291..831c8cdcc 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -286,6 +286,7 @@ static void srpt_event_handler(struct ib_event_handler *handler, { struct srpt_device *sdev; struct srpt_port *sport; + u8 port_num; TRACE_ENTRY(); @@ -298,10 +299,15 @@ static void srpt_event_handler(struct ib_event_handler *handler, switch (event->event) { case IB_EVENT_PORT_ERR: - if (event->element.port_num <= sdev->device->phys_port_cnt) { - sport = &sdev->port[event->element.port_num - 1]; + port_num = event->element.port_num; + if (1 <= port_num && port_num <= sdev->device->phys_port_cnt) { + sport = &sdev->port[port_num - 1]; sport->lid = 0; sport->sm_lid = 0; + } else { + WARN(true, "event %d: port_num %d out of range 1..%d\n", + event->event, port_num, + sdev->device->phys_port_cnt); } break; case IB_EVENT_PORT_ACTIVE: @@ -310,10 +316,15 @@ static void srpt_event_handler(struct ib_event_handler *handler, case IB_EVENT_SM_CHANGE: case IB_EVENT_CLIENT_REREGISTER: /* Refresh port data asynchronously. */ - if (event->element.port_num <= sdev->device->phys_port_cnt) { - sport = &sdev->port[event->element.port_num - 1]; + port_num = event->element.port_num; + if (1 <= port_num && port_num <= sdev->device->phys_port_cnt) { + sport = &sdev->port[port_num - 1]; if (!sport->lid && !sport->sm_lid) schedule_work(&sport->work); + } else { + WARN(true, "event %d: port_num %d out of range 1..%d\n", + event->event, port_num, + sdev->device->phys_port_cnt); } break; default: