Skip to contentSkip to conversation

net/mlx4: off by one in parse_trans_rule()

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 11, 2012 – Jul 17, 2012

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

PATCH 1/1 net/mlx4: off by one in parse_trans_rule()

This should be ">=" here instead of ">". MLX4_NET_TRANS_RULE_NUM is 6. We use "spec->id" as an array offset into the __rule_hw_sz[] and __sw_id_hw[] arrays which have 6 elements.

drivers/net/ethernet/mellanox/mlx4/mcg.c +1 -1
index bc62f53..5bac0df 100644
@@ -773,7 +773,7 @@ static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec,
 		[MLX4_NET_TRANS_RULE_ID_UDP]  			sizeof(struct mlx4_net_trans_rule_hw_tcp_udp)
 	};
-	if (spec->id > MLX4_NET_TRANS_RULE_NUM) {
+	if (spec->id >= MLX4_NET_TRANS_RULE_NUM) {
 		mlx4_err(dev, "Invalid network rule id. id = %d\n", spec->id);
 		return -EINVAL;
 	}
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dan Carpenter

This should be ">=" here instead of ">". MLX4_NET_TRANS_RULE_NUM is 6. We use "spec->id" as an array offset into the __rule_hw_sz[] and __sw_id_hw[] arrays which have 6 elements.

drivers/net/ethernet/mellanox/mlx4/mcg.c +0 -0
index bc62f53..5bac0df 100644

drivers/net/ethernet/mellanox/mlx4/mcg.c static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec, · line 779

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx4/mcg.c +1 -1
@@ -773,7 +773,7 @@ static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec,
  		[MLX4_NET_TRANS_RULE_ID_UDP] >   			sizeof(struct mlx4_net_trans_rule_hw_tcp_udp)
  	};
-	if (spec->id > MLX4_NET_TRANS_RULE_NUM) {
+	if (spec->id >= MLX4_NET_TRANS_RULE_NUM) {
  		mlx4_err(dev, "Invalid network rule id. id = %d\n", spec->id);
  		return -EINVAL;
  	}
 

Hi Dan,

This is indeed a bug, thanks for spotting this over,

Please add:

Hadar

maintainer Applied
#2 lore raw
In reply to Dan Carpenter

From: Dan Carpenter <[email protected]>
Date: Wed, 11 Jul 2012 09:33:36 +0300

Quoted 5 lines

This should be ">=" here instead of ">". MLX4_NET_TRANS_RULE_NUM is 6. We use "spec->id" as an array offset into the __rule_hw_sz[] and __sw_id_hw[] arrays which have 6 elements.

Applied, thanks.

Dan, in the future please indicate clearly that your patches are targetted at net-next specifically. Thanks.