diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-10-03 12:32:33 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-10-17 18:20:27 -0400 |
commit | 116c0074ecfd6f061570856bec52b691d54dbd3c (patch) | |
tree | 0f9524538accf39d965d270d63728ec43a5f26b8 /drivers/infiniband | |
parent | f575394f1de9b4afa4b474f1882c7e2d3b8e51d7 (diff) |
[IB] Check port number in ib_query_port()/ib_modify_port()
Check port number before passing query_port or modify_port operations
on to device driver.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/core/device.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index d3cf84e01587..5a6e44976405 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
@@ -514,6 +514,12 @@ int ib_query_port(struct ib_device *device, | |||
514 | u8 port_num, | 514 | u8 port_num, |
515 | struct ib_port_attr *port_attr) | 515 | struct ib_port_attr *port_attr) |
516 | { | 516 | { |
517 | if (device->node_type == IB_NODE_SWITCH) { | ||
518 | if (port_num) | ||
519 | return -EINVAL; | ||
520 | } else if (port_num < 1 || port_num > device->phys_port_cnt) | ||
521 | return -EINVAL; | ||
522 | |||
517 | return device->query_port(device, port_num, port_attr); | 523 | return device->query_port(device, port_num, port_attr); |
518 | } | 524 | } |
519 | EXPORT_SYMBOL(ib_query_port); | 525 | EXPORT_SYMBOL(ib_query_port); |
@@ -583,6 +589,12 @@ int ib_modify_port(struct ib_device *device, | |||
583 | u8 port_num, int port_modify_mask, | 589 | u8 port_num, int port_modify_mask, |
584 | struct ib_port_modify *port_modify) | 590 | struct ib_port_modify *port_modify) |
585 | { | 591 | { |
592 | if (device->node_type == IB_NODE_SWITCH) { | ||
593 | if (port_num) | ||
594 | return -EINVAL; | ||
595 | } else if (port_num < 1 || port_num > device->phys_port_cnt) | ||
596 | return -EINVAL; | ||
597 | |||
586 | return device->modify_port(device, port_num, port_modify_mask, | 598 | return device->modify_port(device, port_num, port_modify_mask, |
587 | port_modify); | 599 | port_modify); |
588 | } | 600 | } |