Skip to content

Commit

Permalink
net: dsa: mv88e6xxx: lock mutex in port_fdb_dump
Browse files Browse the repository at this point in the history
During a port FDB dump operation, the mutex protecting the concurrent
access to the switch registers is currently held by the internal
mv88e6xxx_port_db_dump and mv88e6xxx_port_db_dump_fid helpers.

It must be held at the higher level in mv88e6xxx_port_fdb_dump which
is called directly by DSA through ds->ops->port_fdb_dump. Fix this.

Signed-off-by: Vivien Didelot <vivien.didelot@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Vivien Didelot authored and David S. Miller committed Jun 12, 2019
1 parent 0114214 commit fcf1536
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions drivers/net/dsa/mv88e6xxx/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,9 +1767,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
eth_broadcast_addr(addr.mac);

do {
mutex_lock(&chip->reg_lock);
err = mv88e6xxx_g1_atu_getnext(chip, fid, &addr);
mutex_unlock(&chip->reg_lock);
if (err)
return err;

Expand Down Expand Up @@ -1802,10 +1800,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
int err;

/* Dump port's default Filtering Information Database (VLAN ID 0) */
mutex_lock(&chip->reg_lock);
err = mv88e6xxx_port_get_fid(chip, port, &fid);
mutex_unlock(&chip->reg_lock);

if (err)
return err;

Expand All @@ -1815,9 +1810,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,

/* Dump VLANs' Filtering Information Databases */
do {
mutex_lock(&chip->reg_lock);
err = mv88e6xxx_vtu_getnext(chip, &vlan);
mutex_unlock(&chip->reg_lock);
if (err)
return err;

Expand All @@ -1837,8 +1830,13 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
dsa_fdb_dump_cb_t *cb, void *data)
{
struct mv88e6xxx_chip *chip = ds->priv;
int err;

mutex_lock(&chip->reg_lock);
err = mv88e6xxx_port_db_dump(chip, port, cb, data);
mutex_unlock(&chip->reg_lock);

return mv88e6xxx_port_db_dump(chip, port, cb, data);
return err;
}

static int mv88e6xxx_bridge_map(struct mv88e6xxx_chip *chip,
Expand Down

0 comments on commit fcf1536

Please sign in to comment.