Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pan Chuang" <panchuang@vivo.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v2 1/7] hwmon: (axi-fan-control) Remove redundant dev_err_probe()
Date: Mon, 20 Jul 2026 06:47:53 +0000	[thread overview]
Message-ID: <20260720064753.75BA91F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260720063745.309331-2-panchuang@vivo.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Pre-existing issues:
- [High] Widespread missing 64-bit casts and unsigned logic errors across sysfs and interrupt callbacks lead to arithmetic overflows on 32-bit architectures, emitting invalid hardware configurations and garbage telemetry data.
- [High] The `fan_fault` state is concurrently accessed by the interrupt handler thread and sysfs reads without locking, directly violating the hwmon subsystem synchronization guidelines.
- [High] The hardware is left active, out of reset, and with unmasked hardware interrupts upon probe failure or module unload.
--

--- Patch [1]: [PATCH v2 1/7] hwmon: (axi-fan-control) Remove redundant dev_err_probe() ---
commit df8b06ee0f4291234f7eb4185e5e9fddf05147c5
Author: Pan Chuang <panchuang@vivo.com>

hwmon: (axi-fan-control) Remove redundant dev_err_probe()

Since commit 55b48e23f5c4 ("genirq/devres: Add error handling in
devm_request_*_irq()"), devm_request_threaded_irq() automatically logs
detailed error messages on failure. Remove the now-redundant
driver-specific dev_err() calls.

> --- a/drivers/hwmon/axi-fan-control.c
> +++ b/drivers/hwmon/axi-fan-control.c
> @@ -508,8 +508,7 @@ static int axi_fan_control_probe(struct platform_device *pdev)
>  					IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
>  					NULL, ctl);
>  	if (ret)
> -		return dev_err_probe(&pdev->dev, ret,
> -				     "failed to request an irq\n");
> +		return ret;

[Severity: High]
This is a pre-existing issue, but if devm_request_threaded_irq() fails here,
does the hardware remain active and out of reset?

axi_fan_control_init() writes to ADI_REG_IRQ_MASK to enable interrupts and
ADI_REG_RSTN to bring the hardware out of reset. If the probe fails at this
point, there doesn't seem to be any cleanup to quiesce the hardware.

There also doesn't appear to be a .remove callback to handle module unload.

[Severity: High]
This isn't a bug introduced by this patch, but do these calculations overflow
on 32-bit architectures?

drivers/hwmon/axi-fan-control.c:axi_fan_control_get_fan_rpm() {
    ...
    return DIV_ROUND_CLOSEST(60 * ctl->clk_rate, ctl->ppr * tach);
    ...
}

For standard clock rates like 100MHz, 60 * ctl->clk_rate would evaluate to
6,000,000,000, which unconditionally overflows a 32-bit unsigned integer.

Similarly, in axi_fan_control_read_temp():

drivers/hwmon/axi-fan-control.c:axi_fan_control_read_temp() {
    ...
    *val = ((raw_temp * 501374) >> 16) - 273677;
    ...
}

For 16-bit ADC values, raw_temp * 501374 exceeds 32-bit signed limits.

Additionally, in axi_fan_control_show(), if the calculated value is negative,
does the subtraction of 280230 underflow into a large positive number since it
is stored in a u32?

[Severity: High]
This is a pre-existing issue, but is there a missing lock around the fan_fault
state?

drivers/hwmon/axi-fan-control.c:axi_fan_control_read_fan() {
    ...
    *val = ctl->fan_fault;
    /* clear it now */
    ctl->fan_fault = 0;
    ...
}

If the hardware triggers an ADI_IRQ_SRC_TACH_ERR interrupt right between the
read and the clear, will the interrupt handler's update be lost?

drivers/hwmon/axi-fan-control.c:axi_fan_control_irq_handler() {
    ...
    if (irq_pending & ADI_IRQ_SRC_TACH_ERR)
        ctl->fan_fault = 1;
    ...
}

It seems this state is accessed concurrently by the interrupt handler thread
and sysfs reads without locking, which might lead to dropped fault indicators.

>  
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720063745.309331-1-panchuang@vivo.com?part=1

  reply	other threads:[~2026-07-20  6:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  6:37 [PATCH v2 0/7] hwmon: Remove redundant error messages on IRQ request failure Pan Chuang
2026-07-20  6:37 ` [PATCH v2 1/7] hwmon: (axi-fan-control) Remove redundant dev_err_probe() Pan Chuang
2026-07-20  6:47   ` sashiko-bot [this message]
2026-07-20 14:32   ` Guenter Roeck
2026-07-20  6:37 ` [PATCH v2 2/7] hwmon: (da9055) Remove redundant dev_err() Pan Chuang
2026-07-20  6:40   ` sashiko-bot
2026-07-20 14:33   ` Guenter Roeck
2026-07-20  6:37 ` [PATCH v2 3/7] hwmon: (lm90) " Pan Chuang
2026-07-20  6:42   ` sashiko-bot
2026-07-20 14:33   ` Guenter Roeck
2026-07-20  6:37 ` [PATCH v2 4/7] hwmon: (npcm750-pwm-fan) " Pan Chuang
2026-07-20  6:52   ` sashiko-bot
2026-07-20 14:34   ` Guenter Roeck
2026-07-20  6:37 ` [PATCH v2 5/7] hwmon: (pwm-fan) " Pan Chuang
2026-07-20  6:45   ` sashiko-bot
2026-07-20 14:35   ` Guenter Roeck
2026-07-20  6:37 ` [PATCH v2 6/7] hwmon: (sht15) " Pan Chuang
2026-07-20  6:47   ` sashiko-bot
2026-07-20 14:35   ` Guenter Roeck
2026-07-20  6:37 ` [PATCH v2 7/7] hwmon: (pmbus) " Pan Chuang
2026-07-20  6:43   ` sashiko-bot
2026-07-20 14:36   ` Guenter Roeck

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=20260720064753.75BA91F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=panchuang@vivo.com \
    --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