From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Jerry Wu <w.7erry@foxmail.com>, vladimir.oltean@nxp.com
Cc: claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com,
UNGLinuxDriver@microchip.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2] net: mscc: ocelot: Fix crash when adding interface under a lag
Date: Sat, 20 Dec 2025 20:58:08 +0100 [thread overview]
Message-ID: <4958770f-3e36-4d90-80ea-4bfca69bb61a@wanadoo.fr> (raw)
In-Reply-To: <tencent_03A0A4FC04B804E36C8245084CD6052D8406@qq.com>
Le 20/12/2025 à 19:56, Jerry Wu a écrit :
> Commit 15faa1f67ab4 ("lan966x: Fix crash when adding interface under a lag")
> fixed a similar issue in the lan966x driver caused by a NULL pointer dereference.
> The ocelot_set_aggr_pgids() function in the ocelot driver has similar logic
> and is susceptible to the same crash.
>
> This issue specifically affects the ocelot_vsc7514.c frontend, which leaves
> unused ports as NULL pointers. The felix_vsc9959.c frontend is unaffected as
> it uses the DSA framework which registers all ports.
>
> Fix this by checking if the port pointer is valid before accessing it.
>
> Fixes: 528d3f190c98 ("net: mscc: ocelot: drop the use of the "lags" array")
> Signed-off-by: Jerry Wu <w.7erry@foxmail.com>
> ---
> drivers/net/ethernet/mscc/ocelot.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
> index 08bee56aea35..6f917fd7af4d 100644
> --- a/drivers/net/ethernet/mscc/ocelot.c
> +++ b/drivers/net/ethernet/mscc/ocelot.c
> @@ -2307,14 +2307,16 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot)
>
> /* Now, set PGIDs for each active LAG */
> for (lag = 0; lag < ocelot->num_phys_ports; lag++) {
> - struct net_device *bond = ocelot->ports[lag]->bond;
> + struct ocelot_port *ocelot_port = ocelot->ports[lag];
Hi,
Does it compile?
Should this be struct ocelot_port *port = ocelot->ports[lag]; ?
CJ
> int num_active_ports = 0;
> + struct net_device *bond;
> unsigned long bond_mask;
> u8 aggr_idx[16];
>
> - if (!bond || (visited & BIT(lag)))
> + if (!port || !port->bond || (visited & BIT(lag)))
> continue;
>
> + bond = port->bond;
> bond_mask = ocelot_get_bond_mask(ocelot, bond);
>
> for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) {
next prev parent reply other threads:[~2025-12-20 19:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-20 18:56 Jerry Wu
2025-12-20 19:58 ` Christophe JAILLET [this message]
2025-12-20 19:01 Jerry Wu
2025-12-20 19:56 ` Vladimir Oltean
2025-12-20 20:00 ` Christophe JAILLET
2025-12-20 20:36 ` Jerry Wu
2025-12-20 21:08 ` Vladimir Oltean
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=4958770f-3e36-4d90-80ea-4bfca69bb61a@wanadoo.fr \
--to=christophe.jaillet@wanadoo.fr \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=claudiu.manoil@nxp.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vladimir.oltean@nxp.com \
--cc=w.7erry@foxmail.com \
/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®