]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: dsa: b53: properly bound ARL searches for < 4 ARL bin chips
authorJonas Gorski <jonas.gorski@gmail.com>
Sun, 2 Nov 2025 10:07:58 +0000 (11:07 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 4 Nov 2025 00:42:43 +0000 (16:42 -0800)
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: cd169d799bee ("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>
drivers/net/dsa/b53/b53_common.c

index b467500699c70df56703e0667b863f9faabcef29..eb767edc4c135bbfe170dd40c33e78fc0cad9240 100644 (file)
@@ -2087,13 +2087,16 @@ static int b53_fdb_copy(int port, const struct b53_arl_entry *ent,
 int b53_fdb_dump(struct dsa_switch *ds, int port,
                 dsa_fdb_dump_cb_t *cb, void *data)
 {
+       unsigned int count = 0, results_per_hit = 1;
        struct b53_device *priv = ds->priv;
        struct b53_arl_entry results[2];
-       unsigned int count = 0;
        u8 offset;
        int ret;
        u8 reg;
 
+       if (priv->num_arl_bins > 2)
+               results_per_hit = 2;
+
        mutex_lock(&priv->arl_mutex);
 
        if (is5325(priv) || is5365(priv))
@@ -2115,7 +2118,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
                if (ret)
                        break;
 
-               if (priv->num_arl_bins > 2) {
+               if (results_per_hit == 2) {
                        b53_arl_search_rd(priv, 1, &results[1]);
                        ret = b53_fdb_copy(port, &results[1], cb, data);
                        if (ret)
@@ -2125,7 +2128,7 @@ int b53_fdb_dump(struct dsa_switch *ds, int port,
                                break;
                }
 
-       } while (count++ < b53_max_arl_entries(priv) / 2);
+       } while (count++ < b53_max_arl_entries(priv) / results_per_hit);
 
        mutex_unlock(&priv->arl_mutex);