ib_srpt: Make port number range checking more strict

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4059 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2012-01-10 12:47:37 +00:00
parent 68ab66d75a
commit 5cedc7a926

View File

@@ -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: