mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: "Colin King (gmail)" <colin.i.king@gmail.com>,
	aryan.srivastava@alliedtelesis.co.nz
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: net: dsa: mv88e6xxx: Add devlink regions
Date: Wed, 9 Oct 2024 18:30:01 +0200	[thread overview]
Message-ID: <4197286c-3403-433a-8d15-3e720c0fa65a@lunn.ch> (raw)
In-Reply-To: <13c4d51e-7209-48c6-883b-661395798a9a@gmail.com>

On Wed, Oct 09, 2024 at 05:20:09PM +0100, Colin King (gmail) wrote:
> Hi Andrew,
> 
> Static analysis on linux-next has detected a potential issue with an
> function returning an uninitialized value from function
> mv88e6xxx_region_atu_snapshot in drivers/net/dsa/mv88e6xxx/devlink.c
> 
> The commit in question is:
> 
> commit bfb255428966e2ab2c406cf6c71d95e9e63241e4
> Author: Andrew Lunn <andrew@lunn.ch>
> Date:   Fri Sep 18 21:11:07 2020 +0200
> 
>     net: dsa: mv88e6xxx: Add devlink regions
> 
> Variable err is not being initialized at the start of the function. In the
> following while-loop err is not being assigned if id == MV88E6XXX_N_FID
> because of the early break out of the loop. This can end up with the
> function returning an uninitialized value in err.

Hi Colin

That is an old commit. I doubt that is the actual cause. What the real
problem is:

Commit ada5c3229b32e48f4c8e09b6937e5ad98cc3675f
Author: Aryan Srivastava <aryan.srivastava@alliedtelesis.co.nz>
Date:   Mon Oct 7 10:29:05 2024 +1300

    net: dsa: mv88e6xxx: Add FID map cache
    
    Add a cached FID bitmap. This mitigates the need to walk all VTU entries
    to find the next free FID.
    
    When flushing the VTU (during init), zero the FID bitmap. Use and
    manipulate this bitmap from now on, instead of reading HW for the FID
    map.
    
    The repeated VTU walks are costly and can take ~40 mins if ~4000 vlans
    are added. Caching the FID map reduces this time to <2 mins.
    
    Signed-off-by: Aryan Srivastava <aryan.srivastava@alliedtelesis.co.nz>
    Reviewed-by: Andrew Lunn <andrew@lunn.ch>
    Link: https://patch.msgid.link/20241006212905.3142976-1-aryan.srivastava@alliedtelesis.co.nz
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c
index a08dab75e0c0..ef3643bc43db 100644
--- a/drivers/net/dsa/mv88e6xxx/devlink.c
+++ b/drivers/net/dsa/mv88e6xxx/devlink.c
@@ -374,7 +374,6 @@ static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
                                         u8 **data)
 {
        struct dsa_switch *ds = dsa_devlink_to_ds(dl);
-       DECLARE_BITMAP(fid_bitmap, MV88E6XXX_N_FID);
        struct mv88e6xxx_devlink_atu_entry *table;
        struct mv88e6xxx_chip *chip = ds->priv;
        int fid = -1, count, err;
@@ -392,14 +391,8 @@ static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
 
        mv88e6xxx_reg_lock(chip);
 
-       err = mv88e6xxx_fid_map(chip, fid_bitmap);
-       if (err) {
-               kfree(table);
-               goto out;
-       }
-

The removed code used to ensure err was initialized.

Aryan, please could you fix this.

	Andrew


      reply	other threads:[~2024-10-09 16:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 16:20 Colin King (gmail)
2024-10-09 16:30 ` Andrew Lunn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4197286c-3403-433a-8d15-3e720c0fa65a@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=aryan.srivastava@alliedtelesis.co.nz \
    --cc=colin.i.king@gmail.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®