Commit a8232c0f authored by Eran Ben Elisha's avatar Eran Ben Elisha Committed by Kleber Sacilotto de Souza

net/mlx4_core: Fix potential corruption in counters database

BugLink: https://bugs.launchpad.net/bugs/1878232

commit 6b94bab0 upstream.

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: 68230242 ('net/mlx4_core: Add port attribute when tracking counters')
Signed-off-by: default avatarEran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 87e9cd3b
...@@ -918,11 +918,13 @@ static int handle_existing_counter(struct mlx4_dev *dev, u8 slave, int port, ...@@ -918,11 +918,13 @@ static int handle_existing_counter(struct mlx4_dev *dev, u8 slave, int port,
spin_lock_irq(mlx4_tlock(dev)); spin_lock_irq(mlx4_tlock(dev));
r = find_res(dev, counter_index, RES_COUNTER); r = find_res(dev, counter_index, RES_COUNTER);
if (!r || r->owner != slave) if (!r || r->owner != slave) {
ret = -EINVAL; ret = -EINVAL;
} else {
counter = container_of(r, struct res_counter, com); counter = container_of(r, struct res_counter, com);
if (!counter->port) if (!counter->port)
counter->port = port; counter->port = port;
}
spin_unlock_irq(mlx4_tlock(dev)); spin_unlock_irq(mlx4_tlock(dev));
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment