gianfar: Fix overflow check and return value for gfar_get_cls_all()
Subsystems (2)
PATCH 1/1 gianfar: Fix overflow check and return value for gfar_get_cls_all()
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 <[email protected]>
---
This code is new for 3.1, so no stable update required.
Not tested in any way, as this driver depends on FSL_SOC.
Ben.
drivers/net/gianfar_ethtool.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/gianfar_ethtool.c +4 -4
@@ -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 ;
Signature · 7 lines
1.7.4.4 -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
David Miller
AppliedFrom: Ben Hutchings <[email protected]>
Date: Tue, 06 Sep 2011 23:44:25 +0100
Quoted 5 lines
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 <[email protected]>
Applied, thanks a lot Ben.