Skip to content

Commit

Permalink
[IB] Check port number in ib_query_port()/ib_modify_port()
Browse files Browse the repository at this point in the history
Check port number before passing query_port or modify_port operations
on to device driver.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
  • Loading branch information
Roland Dreier committed Oct 17, 2005
1 parent f575394 commit 116c007
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/infiniband/core/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 116c007

Please sign in to comment.