From: sashiko-bot@kernel.org
To: "Oleksij Rempel" <o.rempel@pengutronix.de>
Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v13 5/6] hwmon: add NXP MC33978/MC34978 driver
Date: Mon, 18 May 2026 12:15:02 +0000 [thread overview]
Message-ID: <20260518121503.4A558C2BCC7@smtp.kernel.org> (raw)
In-Reply-To: <20260518100054.3552143-6-o.rempel@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Background polling worker unconditionally re-arms itself during teardown, leading to a Use-After-Free.
--
commit 120174fd926c55b417dcd675badea0f431859a73
Author: Oleksij Rempel <o.rempel@pengutronix.de>
hwmon: add NXP MC33978/MC34978 driver
This commit adds hardware monitoring support for the NXP MC33978/MC34978
Multiple Switch Detection Interface (MSDI). It implements an edge-triggered
interrupt handler paired with a polling delayed workqueue to manage persistent
hardware faults.
> diff --git a/drivers/hwmon/mc33978-hwmon.c b/drivers/hwmon/mc33978-hwmon.c
> new file mode 100644
> index 0000000000000..bd4dd25b3b20a
> --- /dev/null
> +++ b/drivers/hwmon/mc33978-hwmon.c
[ ... ]
> +static int mc33978_hwmon_update_faults(struct mc33978_hwmon_priv *priv)
> +{
[ ... ]
> + ret = mc33978_hwmon_read_fault(priv, &faults);
> + if (ret) {
> + hwmon_unlock(priv->hwmon_dev);
> + dev_err_ratelimited(priv->dev,
> + "failed to read fault register: %pe\n",
> + ERR_PTR(ret));
> + /*
> + * Always retry on read failure. If we drop the heartbeat during
> + * the initial fault before caching it, the edge-triggered IRQ
> + * will never fire again and permanently stall fault monitoring.
> + */
> + rearm = true;
> + goto out_poll;
> + }
[ ... ]
> + rearm = !!alarm_faults;
> +
> +out_poll:
> + /*
> + * If any alarms are currently active, the global FAULT_STAT bit remains
> + * asserted. The hardware will not generate a new rising edge interrupt
> + * if a secondary fault occurs, nor will it interrupt when faults clear.
> + * Schedule a poll to detect both clearing edges and secondary alarms.
> + */
> + if (rearm)
> + /* Use freezable polling to pause while the system is suspended. */
> + mod_delayed_work(system_freezable_wq, &priv->poll_work,
> + msecs_to_jiffies(MC33978_FAULT_POLL_INTERVAL_MS));
> +
> + return ret;
> +}
[ ... ]
> +static void mc33978_hwmon_action_cancel_work(void *data)
> +{
> + struct mc33978_hwmon_priv *priv = data;
> +
> + cancel_delayed_work_sync(&priv->poll_work);
> +}
During device removal, devres calls mc33978_hwmon_action_cancel_work(), which
uses cancel_delayed_work_sync(). If the work is concurrently executing,
cancel_delayed_work_sync() will wait for the worker to finish.
Inside the running worker, mc33978_hwmon_update_faults() attempts a
regmap_read(). Since the device is being removed, this read is likely to fail
or return persistent physical faults, setting rearm to true. The worker then
calls mod_delayed_work() and queues the underlying timer to fire again.
When cancel_delayed_work_sync() observes the completion of the execution, it
returns without canceling the newly re-armed timer. The teardown sequence then
continues, freeing the devm-allocated priv structure.
When the timer expires, could this cause a use-after-free when the kernel timer
subsystem dereferences the freed priv->poll_work.timer memory? Should there be
a state flag to prevent re-arming the work during teardown?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260518100054.3552143-1-o.rempel@pengutronix.de?part=5
next prev parent reply other threads:[~2026-05-18 12:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-18 10:00 [PATCH v13 0/6] mfd: Add support for NXP MC33978/MC34978 MSDI Oleksij Rempel
2026-05-18 10:00 ` [PATCH v13 1/6] dt-bindings: pinctrl: add " Oleksij Rempel
2026-05-18 10:00 ` [PATCH v13 2/6] mfd: add NXP MC33978/MC34978 core driver Oleksij Rempel
2026-05-18 10:40 ` sashiko-bot
2026-05-18 10:00 ` [PATCH v13 3/6] pinctrl: core: Make pin group callbacks optional for pin-only drivers Oleksij Rempel
2026-05-18 11:19 ` sashiko-bot
2026-05-18 10:00 ` [PATCH v13 4/6] pinctrl: add NXP MC33978/MC34978 pinctrl driver Oleksij Rempel
2026-05-18 11:46 ` sashiko-bot
2026-05-18 10:00 ` [PATCH v13 5/6] hwmon: add NXP MC33978/MC34978 driver Oleksij Rempel
2026-05-18 12:15 ` sashiko-bot [this message]
2026-05-18 10:00 ` [PATCH v13 6/6] mux: add NXP MC33978/MC34978 AMUX driver Oleksij Rempel
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=20260518121503.4A558C2BCC7@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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