Skip to content

Commit e57723f

Browse files
KanjiMonsterkuba-moo
authored andcommitted
net: dsa: b53: properly bound ARL searches for < 4 ARL bin chips
When iterating over the ARL table we stop at max ARL entries / 2, but this is only valid if the chip actually returns 2 results at once. For chips with only one result register we will stop before reaching the end of the table if it is more than half full. Fix this by only dividing the maximum results by two if we have a chip with more than one result register (i.e. those with 4 ARL bins). Fixes: cd169d7 ("net: dsa: b53: Bound check ARL searches") Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://patch.msgid.link/20251102100758.28352-4-jonas.gorski@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 0be04b5 commit e57723f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/net/dsa/b53/b53_common.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,13 +2087,16 @@ static int b53_fdb_copy(int port, const struct b53_arl_entry *ent,
20872087
int b53_fdb_dump(struct dsa_switch *ds, int port,
20882088
dsa_fdb_dump_cb_t *cb, void *data)
20892089
{
2090+
unsigned int count = 0, results_per_hit = 1;
20902091
struct b53_device *priv = ds->priv;
20912092
struct b53_arl_entry results[2];
2092-
unsigned int count = 0;
20932093
u8 offset;
20942094
int ret;
20952095
u8 reg;
20962096

2097+
if (priv->num_arl_bins > 2)
2098+
results_per_hit = 2;
2099+
20972100
mutex_lock(&priv->arl_mutex);
20982101

20992102
if (is5325(priv) || is5365(priv))
@@ -2115,7 +2118,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
21152118
if (ret)
21162119
break;
21172120

2118-
if (priv->num_arl_bins > 2) {
2121+
if (results_per_hit == 2) {
21192122
b53_arl_search_rd(priv, 1, &results[1]);
21202123
ret = b53_fdb_copy(port, &results[1], cb, data);
21212124
if (ret)
@@ -2125,7 +2128,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
21252128
break;
21262129
}
21272130

2128-
} while (count++ < b53_max_arl_entries(priv) / 2);
2131+
} while (count++ < b53_max_arl_entries(priv) / results_per_hit);
21292132

21302133
mutex_unlock(&priv->arl_mutex);
21312134

0 commit comments

Comments
 (0)