From: sashiko-bot@kernel.org
To: "Zinc Lim" <limzhineng2@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH net-next 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events
Date: Wed, 22 Jul 2026 22:18:02 +0000 [thread overview]
Message-ID: <20260722221802.9F8E21F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260721221540.648272-7-limzhineng2@gmail.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
New issues:
- [Medium] Uninitialized sensor thresholds default to S32_MIN, causing alarm checks to always evaluate to true and trigger incorrect alarms.
- [Low] Missing IS_REACHABLE(CONFIG_HWMON) guard in fbnic_hwmon_notify_event causes a linker error when CONFIG_HWMON is disabled.
Pre-existing issues:
- [High] Error path in fbnic_fw_request_mbx saves a freed IRQ vector, leading to a double-free on device removal.
--
--- Patch [6]: [PATCH net-next 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events ---
commit 47c1b3bcb6116f975f3ccbd306542f2c5e9bd4f2
Author: Zinc Lim <limzhineng2@gmail.com>
eth: fbnic: firmware notifies hwmon on sensor threshold events
The firmware sends an unsolicited message via the new
FBNIC_TLV_MSG_ID_SENSOR_THRESHOLD_EXCEEDED_RESP IPC message when a
temperature or voltage sensor crosses one of its thresholds. Parse this
message and translate it into the corresponding hwmon alarm
(temp1_{min,max,crit}_alarm or in0_{min,max}_alarm) via
hwmon_notify_event(), so userspace listeners are woken on the relevant
sysfs attribute.
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> index c5cddd9cef124..eb910ba47f378 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
[ ... ]
> @@ -214,22 +216,72 @@ void fbnic_hwmon_register(struct fbnic_dev *fbd)
[ ... ]
> +void fbnic_hwmon_notify_event(struct fbnic_dev *fbd, int id, long val)
> +{
> + enum hwmon_sensor_types type;
> + struct device *hwmon;
> + s32 attr = -1;
> +
> + switch (id) {
> + case FBNIC_SENSOR_TEMP:
> + type = hwmon_temp;
> +
> + if (val <= fbd->fw_cap.temp.min)
> + attr = hwmon_temp_min_alarm;
> + else if (val >= fbd->fw_cap.temp.crit)
> + attr = hwmon_temp_crit_alarm;
[Severity: Medium]
Will this evaluate to true if the firmware does not provide a critical
threshold?
It appears that fbnic_fw_parse_cap_resp() initializes these thresholds to the
sentinel value FBNIC_SENSOR_NO_DATA (S32_MIN) when they aren't provided.
Since S32_MIN is the minimum possible 32-bit integer, any valid temperature
reading will be greater than S32_MIN, causing this condition to incorrectly
evaluate to true and preventing subsequent valid threshold checks from being
evaluated.
> + else if (val >= fbd->fw_cap.temp.max)
> + attr = hwmon_temp_max_alarm;
> +
> + break;
> + case FBNIC_SENSOR_VOLTAGE:
> + type = hwmon_in;
> +
> + if (val <= fbd->fw_cap.volt.min)
> + attr = hwmon_in_min_alarm;
> + else if (val >= fbd->fw_cap.volt.max)
> + attr = hwmon_in_max_alarm;
> +
> + break;
> + default:
> + return;
> + }
> +
> + /* Pair with WRITE_ONCE() in fbnic_hwmon_unregister(). Skip the
> + * notification if hwmon failed to register or has already been torn
> + * down.
> + */
> + hwmon = READ_ONCE(fbd->hwmon);
> + if (attr >= 0 && hwmon)
> + hwmon_notify_event(hwmon, type, attr, 0);
[Severity: Low]
Does this result in a linker error if CONFIG_HWMON is disabled?
Since fbnic_hwmon_notify_event() is built unconditionally when CONFIG_FBNIC
is enabled, and hwmon_notify_event() is declared in include/linux/hwmon.h
without a fallback stub for !CONFIG_HWMON, calling it without an
IS_REACHABLE(CONFIG_HWMON) guard will cause the linker to fail to resolve
hwmon_notify_event().
> }
[Severity: High]
This is a pre-existing issue, but does the error path in
fbnic_fw_request_mbx() save a freed IRQ vector?
drivers/net/ethernet/meta/fbnic/fbnic_irq.c:fbnic_fw_request_mbx() {
...
if (err)
free_irq(vector, fbd);
fbd->fw_msix_vector = vector;
...
}
If a device resumes from suspend and this path fails, fbd->fw_msix_vector
is left holding the freed vector number.
Later, when the device is removed, fbnic_remove() invokes fbnic_fw_free_mbx().
Since fbd->fw_msix_vector is non-zero, it skips the safety check and attempts
to free the already freed vector, leading to a double-free.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721221540.648272-1-limzhineng2@gmail.com?part=6
prev parent reply other threads:[~2026-07-22 22:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 22:15 [PATCH net-next 0/6] eth: fbnic: expand hwmon sensor support Zinc Lim
2026-07-21 22:15 ` [PATCH net-next 1/6] eth: fbnic: move sensor read logic out of fbnic_mac Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 2/6] eth: fbnic: expose all hwmon attributes unconditionally as read-only Zinc Lim
2026-07-22 22:18 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 3/6] eth: fbnic: cache hwmon sensor readings Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 4/6] eth: fbnic: report temperature and voltage thresholds via hwmon Zinc Lim
2026-07-22 22:18 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 5/6] eth: fbnic: report temperature and voltage alarms " Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events Zinc Lim
2026-07-22 22:18 ` sashiko-bot [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=20260722221802.9F8E21F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=limzhineng2@gmail.com \
--cc=linux-hwmon@vger.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