Skip to content

Commit

Permalink
net: ethernet: ti: ale: fix port check in cpsw_ale_control_set/get
Browse files Browse the repository at this point in the history
ALE ports number includes the Host port and ext Ports, and
ALE ports numbering starts from 0, so correct corresponding port
checks in cpsw_ale_control_set/get().

Signed-off-by: Grygorii Strashko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
grygoriyS authored and davem330 committed Dec 1, 2017
1 parent 1971ab5 commit 9719360
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/ti/cpsw_ale.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ int cpsw_ale_control_set(struct cpsw_ale *ale, int port, int control,
if (info->port_offset == 0 && info->port_shift == 0)
port = 0; /* global, port is a dont care */

if (port < 0 || port > ale->params.ale_ports)
if (port < 0 || port >= ale->params.ale_ports)
return -EINVAL;

mask = BITMASK(info->bits);
Expand Down Expand Up @@ -754,7 +754,7 @@ int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control)
if (info->port_offset == 0 && info->port_shift == 0)
port = 0; /* global, port is a dont care */

if (port < 0 || port > ale->params.ale_ports)
if (port < 0 || port >= ale->params.ale_ports)
return -EINVAL;

offset = info->offset + (port * info->port_offset);
Expand Down

0 comments on commit 9719360

Please sign in to comment.