From: Paolo Abeni <pabeni@redhat.com>
To: daniel@makrotopia.org
Cc: jiri@resnulli.us, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
corbet@lwn.net, skhan@linuxfoundation.org, andrew@lunn.ch,
olteanv@gmail.com, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v10 3/5] net: dsa: mxl862xx: add devlink flash_update and info_get
Date: Thu, 13 Aug 2026 10:22:33 +0200 [thread overview]
Message-ID: <20260813082233.71011-1-pabeni@redhat.com> (raw)
In-Reply-To: <66aaa1b09b0f2e9e74a7274a878c6902e1aa2b9c.1786294649.git.daniel@makrotopia.org>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev/
---
Subject: net: dsa: mxl862xx: add devlink flash_update and info_get
This commit implements runtime firmware upgrading for the MxL862xx switch
using devlink dev flash. It transfers the firmware image over SB PDI,
reboots the switch, and defers a device reprobe to re-initialize the driver
using a workqueue.
> diff --git a/drivers/net/dsa/mxl862xx/mxl862xx-fw.c b/drivers/net/dsa/mxl862xx/mxl862xx-fw.c
> new file mode 100644
> index 0000000000000..9799cf19d31a9
> --- /dev/null
> +++ b/drivers/net/dsa/mxl862xx/mxl862xx-fw.c
[ ... ]
> +static void mxl862xx_reprobe_work_fn(struct work_struct *work)
> +{
> + struct mxl862xx_reprobe *rp =
> + container_of(work, struct mxl862xx_reprobe, work.work);
> + struct device *dev = rp->dev;
> + bool bound;
> +
> + device_lock(dev);
> + bound = !!dev_get_drvdata(dev);
> + device_unlock(dev);
> +
> + if (!bound)
> + dev_dbg(dev, "reprobe skipped, device is gone\n");
> + else if (device_reprobe(dev))
[Severity: High]
Is there a race window here that can lead to a use-after-free of priv?
If device_shutdown() runs after device_unlock() but before
device_reprobe(), it can clear drvdata. When device_reprobe() subsequently
runs, it triggers the driver remove() function, which returns early because
drvdata is NULL, bypassing dsa_unregister_switch().
However, because priv was allocated with devm_kzalloc() during probe:
drivers/net/dsa/mxl862xx/mxl862xx.c:mxl862xx_probe() {
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
...
}
the driver core will still run devres_release_all() and free priv. The DSA
switch remains registered, and any subsequent access to it via devlink or
netlink could dereference the freed priv pointer.
> + dev_err(dev, "reprobe failed; device left unbound\n");
> +
> + put_device(dev);
> + kfree(rp);
> + module_put(THIS_MODULE);
> +}
[Severity: High]
Can this cause a kernel panic if the module is unloaded concurrently?
Calling module_put(THIS_MODULE) at the very end of a work item means the
module reference count drops to zero before the function fully returns to
the workqueue core.
A concurrent rmmod can then proceed and unmap the module text section. If
the worker thread is preempted or delayed, it will resume execution from
unmapped memory during the function epilogue, leading to a fatal page fault.
--
This is an AI-generated review.
next prev parent reply other threads:[~2026-08-13 8:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 17:05 [PATCH net-next v10 0/5] net: dsa: mxl862xx: devlink flash and rescue Daniel Golle
2026-08-09 17:06 ` [PATCH net-next v10 1/5] net: dsa: add devlink flash_update callback to dsa_switch_ops Daniel Golle
2026-08-09 17:06 ` [PATCH net-next v10 2/5] net: dsa: mxl862xx: add SMDIO clause-22 register access Daniel Golle
2026-08-09 17:07 ` [PATCH net-next v10 3/5] net: dsa: mxl862xx: add devlink flash_update and info_get Daniel Golle
2026-08-13 8:22 ` Paolo Abeni [this message]
2026-08-13 9:54 ` Daniel Golle
2026-08-09 17:08 ` [PATCH net-next v10 4/5] net: dsa: mxl862xx: recover switch stuck in MCUboot rescue mode Daniel Golle
2026-08-09 17:09 ` [PATCH net-next v10 5/5] net: dsa: mxl862xx: document devlink flash and info support Daniel Golle
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=20260813082233.71011-1-pabeni@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=skhan@linuxfoundation.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