summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox
diff options
context:
space:
mode:
authorEran Ben Elisha <eranbe@mellanox.com>2016-02-17 17:24:24 +0200
committerDavid S. Miller <davem@davemloft.net>2016-02-17 10:29:26 -0500
commit6b94bab0ee8d5def6a2aac0ef6204ee6e24386b6 (patch)
treeba737a483be69af809505f4d95d4bc440292f02a /drivers/net/ethernet/mellanox
parent31c128b66e5b28f468076e4f3ca3025c35342041 (diff)
downloadtalos-obmc-linux-6b94bab0ee8d5def6a2aac0ef6204ee6e24386b6.tar.gz
talos-obmc-linux-6b94bab0ee8d5def6a2aac0ef6204ee6e24386b6.zip
net/mlx4_core: Fix potential corruption in counters database
The error flow in procedure handle_existing_counter() is wrong. The procedure should exit after encountering the error, not continue as if everything is OK. Fixes: 68230242cdbc ('net/mlx4_core: Add port attribute when tracking counters') Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mellanox')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index b46dbe29ef6c..25ce1b030a00 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -915,11 +915,13 @@ static int handle_existing_counter(struct mlx4_dev *dev, u8 slave, int port,
spin_lock_irq(mlx4_tlock(dev));
r = find_res(dev, counter_index, RES_COUNTER);
- if (!r || r->owner != slave)
+ if (!r || r->owner != slave) {
ret = -EINVAL;
- counter = container_of(r, struct res_counter, com);
- if (!counter->port)
- counter->port = port;
+ } else {
+ counter = container_of(r, struct res_counter, com);
+ if (!counter->port)
+ counter->port = port;
+ }
spin_unlock_irq(mlx4_tlock(dev));
return ret;
OpenPOWER on IntegriCloud