Skip to content

Commit

Permalink
gianfar: Fix overflow check and return value for gfar_get_cls_all()
Browse files Browse the repository at this point in the history
This function may currently fill one entry beyond the end of the
array it is given.  It also doesn't return an error code in case
it does detect overflow.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ben Hutchings authored and David S. Miller committed Sep 20, 2011
1 parent 22e83a2 commit 710778f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/net/gianfar_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,10 @@ static int gfar_get_cls_all(struct gfar_private *priv,
u32 i = 0;

list_for_each_entry(comp, &priv->rx_list.list, list) {
if (i <= cmd->rule_cnt) {
rule_locs[i] = comp->fs.location;
i++;
}
if (i == cmd->rule_cnt)
return -EMSGSIZE;
rule_locs[i] = comp->fs.location;
i++;
}

cmd->data = MAX_FILER_IDX;
Expand Down

0 comments on commit 710778f

Please sign in to comment.