diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-10-03 09:32:33 -0700 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-10-17 15:20:27 -0700 |
commit | 116c0074ecfd6f061570856bec52b691d54dbd3c (patch) | |
tree | 0f9524538accf39d965d270d63728ec43a5f26b8 /drivers/infiniband/core | |
parent | f575394f1de9b4afa4b474f1882c7e2d3b8e51d7 (diff) | |
download | blackbird-op-linux-116c0074ecfd6f061570856bec52b691d54dbd3c.tar.gz blackbird-op-linux-116c0074ecfd6f061570856bec52b691d54dbd3c.zip |
[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/core')
-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, u8 port_num, struct ib_port_attr *port_attr) { + if (device->node_type == IB_NODE_SWITCH) { + if (port_num) + return -EINVAL; + } else if (port_num < 1 || port_num > device->phys_port_cnt) + return -EINVAL; + return device->query_port(device, port_num, port_attr); } EXPORT_SYMBOL(ib_query_port); @@ -583,6 +589,12 @@ int ib_modify_port(struct ib_device *device, u8 port_num, int port_modify_mask, struct ib_port_modify *port_modify) { + if (device->node_type == IB_NODE_SWITCH) { + if (port_num) + return -EINVAL; + } else if (port_num < 1 || port_num > device->phys_port_cnt) + return -EINVAL; + return device->modify_port(device, port_num, port_modify_mask, port_modify); } |