Skip to contentSkip to conversation

gianfar: Fix overflow check and return value for gfar_get_cls_all()

PATCH Applied Ben Hutchings 2 participants 2 messages Sep 6, 2011 – Sep 20, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

---
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
index 25a8c2a..0caf3c3 100644
@@ -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.
Applied
#1 lore raw

From: 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.

Applied, thanks a lot Ben.