From: sashiko-bot@kernel.org
To: "Ronald Claveau" <linux-kernel-dev@aliel.fr>
Cc: mfd@lists.linux.dev, robh@kernel.org, devicetree@vger.kernel.org,
neil.armstrong@linaro.org, conor+dt@kernel.org,
linux-amlogic@lists.infradead.org, lee@kernel.org
Subject: Re: [PATCH v9 5/6] arm64: dts: amlogic: t7: Add i2c controller node
Date: Wed, 05 Aug 2026 08:19:10 +0000 [thread overview]
Message-ID: <20260805081910.DBA191F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-add-mcu-fan-khadas-vim4-v9-5-75df78710b9e@aliel.fr>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Probe fails for generic Khadas MCU devices because match data evaluates to NULL.
- [Medium] The fan regulator is leaked on probe error and driver unbind.
--
--- Patch [5]: [PATCH v9 5/6] arm64: dts: amlogic: t7: Add i2c controller node ---
commit b6b3cf68d983172e0dc3e121aff82af7de674ddb
Author: Ronald Claveau <linux-kernel-dev@aliel.fr>
arm64: dts: amlogic: t7: Add i2c controller node
Add the T7 i2c controller node used by the Khadas VIM4 for MCU communication.
Use amlogic,meson-axg-i2c as fallback compatible.
> diff --git a/drivers/mfd/khadas-mcu.c b/drivers/mfd/khadas-mcu.c
> index ba981a7886921..4cb305ac915e1 100644
> --- a/drivers/mfd/khadas-mcu.c
> +++ b/drivers/mfd/khadas-mcu.c
[ ... ]
> @@ -75,47 +75,138 @@ static const struct regmap_config khadas_mcu_regmap_config = {
[ ... ]
> static int khadas_mcu_probe(struct i2c_client *client)
> {
> + const struct mfd_cell *cells, *fan_cells;
> + const struct regmap_config *regmap_cfg;
> struct device *dev = &client->dev;
> + int ncells, nfan_cells, ret;
> struct khadas_mcu *ddata;
> - int ret;
> + const void *match;
>
> ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
> if (!ddata)
> return -ENOMEM;
>
> + match = i2c_get_match_data(client);
> + if (!match)
> + return -ENODEV;
> +
> + switch ((uintptr_t)match) {
> + case KHADAS_MCU_GENERIC:
[Severity: High]
Does this check unintentionally abort probe for generic Khadas MCU devices?
Because KHADAS_MCU_GENERIC is 0, the data field in the match table is
effectively a null pointer:
{ .compatible = "khadas,mcu", .data = (void *)KHADAS_MCU_GENERIC }
When khadas_mcu_probe() is called for a generic device, i2c_get_match_data()
returns NULL. The check for (!match) is met, and the driver unconditionally
returns -ENODEV. This causes a regression for all generic Khadas MCU boards.
[ ... ]
> diff --git a/drivers/thermal/khadas_mcu_fan.c b/drivers/thermal/khadas_mcu_fan.c
> index 21b3d0a71bd0d..c7f74394b823f 100644
> --- a/drivers/thermal/khadas_mcu_fan.c
> +++ b/drivers/thermal/khadas_mcu_fan.c
[ ... ]
> @@ -78,6 +81,7 @@ static const struct thermal_cooling_device_ops khadas_mcu_fan_cooling_ops = {
[ ... ]
> static int khadas_mcu_fan_probe(struct platform_device *pdev)
> {
> + const struct khadas_mcu_fan_pdata *pdata = dev_get_platdata(&pdev->dev);
> struct khadas_mcu *mcu = dev_get_drvdata(pdev->dev.parent);
> struct thermal_cooling_device *cdev;
> struct device *dev = &pdev->dev;
> @@ -87,7 +91,22 @@ static int khadas_mcu_fan_probe(struct platform_device *pdev)
> ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> if (!ctx)
> return -ENOMEM;
> +
> ctx->mcu = mcu;
> + ctx->fan_reg = pdata->fan_reg;
> + ctx->levels = pdata->levels;
> + ctx->nlevels = pdata->nlevels;
> +
> + ctx->power = devm_regulator_get(dev->parent, "fan");
> + if (IS_ERR(ctx->power))
> + return PTR_ERR(ctx->power);
> +
> + ret = regulator_enable(ctx->power);
> + if (ret) {
> + dev_err(dev, "Failed to enable fan power supply: %d\n", ret);
> + return ret;
> + }
> +
> platform_set_drvdata(pdev, ctx);
>
> cdev = devm_thermal_of_child_cooling_device_register(dev->parent,
[Severity: Medium]
Could this leak the regulator on probe error or driver unbind?
If devm_thermal_of_child_cooling_device_register() fails later in
khadas_mcu_fan_probe(), the function returns without calling
regulator_disable().
Additionally, there is no remove callback in khadas_mcu_fan_driver:
static struct platform_driver khadas_mcu_fan_driver = {
.probe = khadas_mcu_fan_probe,
.shutdown = khadas_mcu_fan_shutdown,
.driver = { ...
This means the regulator is not cleanly disabled when the driver is unbound,
which could leave the reference leaked and prevent the regulator from ever
being powered down.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-add-mcu-fan-khadas-vim4-v9-0-75df78710b9e@aliel.fr?part=5
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Ronald Claveau" <linux-kernel-dev@aliel.fr>
Cc: mfd@lists.linux.dev, robh@kernel.org, devicetree@vger.kernel.org,
neil.armstrong@linaro.org, conor+dt@kernel.org,
linux-amlogic@lists.infradead.org, lee@kernel.org
Subject: Re: [PATCH v9 5/6] arm64: dts: amlogic: t7: Add i2c controller node
Date: Wed, 05 Aug 2026 08:19:10 +0000 [thread overview]
Message-ID: <20260805081910.DBA191F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-add-mcu-fan-khadas-vim4-v9-5-75df78710b9e@aliel.fr>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Probe fails for generic Khadas MCU devices because match data evaluates to NULL.
- [Medium] The fan regulator is leaked on probe error and driver unbind.
--
--- Patch [5]: [PATCH v9 5/6] arm64: dts: amlogic: t7: Add i2c controller node ---
commit b6b3cf68d983172e0dc3e121aff82af7de674ddb
Author: Ronald Claveau <linux-kernel-dev@aliel.fr>
arm64: dts: amlogic: t7: Add i2c controller node
Add the T7 i2c controller node used by the Khadas VIM4 for MCU communication.
Use amlogic,meson-axg-i2c as fallback compatible.
> diff --git a/drivers/mfd/khadas-mcu.c b/drivers/mfd/khadas-mcu.c
> index ba981a7886921..4cb305ac915e1 100644
> --- a/drivers/mfd/khadas-mcu.c
> +++ b/drivers/mfd/khadas-mcu.c
[ ... ]
> @@ -75,47 +75,138 @@ static const struct regmap_config khadas_mcu_regmap_config = {
[ ... ]
> static int khadas_mcu_probe(struct i2c_client *client)
> {
> + const struct mfd_cell *cells, *fan_cells;
> + const struct regmap_config *regmap_cfg;
> struct device *dev = &client->dev;
> + int ncells, nfan_cells, ret;
> struct khadas_mcu *ddata;
> - int ret;
> + const void *match;
>
> ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
> if (!ddata)
> return -ENOMEM;
>
> + match = i2c_get_match_data(client);
> + if (!match)
> + return -ENODEV;
> +
> + switch ((uintptr_t)match) {
> + case KHADAS_MCU_GENERIC:
[Severity: High]
Does this check unintentionally abort probe for generic Khadas MCU devices?
Because KHADAS_MCU_GENERIC is 0, the data field in the match table is
effectively a null pointer:
{ .compatible = "khadas,mcu", .data = (void *)KHADAS_MCU_GENERIC }
When khadas_mcu_probe() is called for a generic device, i2c_get_match_data()
returns NULL. The check for (!match) is met, and the driver unconditionally
returns -ENODEV. This causes a regression for all generic Khadas MCU boards.
[ ... ]
> diff --git a/drivers/thermal/khadas_mcu_fan.c b/drivers/thermal/khadas_mcu_fan.c
> index 21b3d0a71bd0d..c7f74394b823f 100644
> --- a/drivers/thermal/khadas_mcu_fan.c
> +++ b/drivers/thermal/khadas_mcu_fan.c
[ ... ]
> @@ -78,6 +81,7 @@ static const struct thermal_cooling_device_ops khadas_mcu_fan_cooling_ops = {
[ ... ]
> static int khadas_mcu_fan_probe(struct platform_device *pdev)
> {
> + const struct khadas_mcu_fan_pdata *pdata = dev_get_platdata(&pdev->dev);
> struct khadas_mcu *mcu = dev_get_drvdata(pdev->dev.parent);
> struct thermal_cooling_device *cdev;
> struct device *dev = &pdev->dev;
> @@ -87,7 +91,22 @@ static int khadas_mcu_fan_probe(struct platform_device *pdev)
> ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
> if (!ctx)
> return -ENOMEM;
> +
> ctx->mcu = mcu;
> + ctx->fan_reg = pdata->fan_reg;
> + ctx->levels = pdata->levels;
> + ctx->nlevels = pdata->nlevels;
> +
> + ctx->power = devm_regulator_get(dev->parent, "fan");
> + if (IS_ERR(ctx->power))
> + return PTR_ERR(ctx->power);
> +
> + ret = regulator_enable(ctx->power);
> + if (ret) {
> + dev_err(dev, "Failed to enable fan power supply: %d\n", ret);
> + return ret;
> + }
> +
> platform_set_drvdata(pdev, ctx);
>
> cdev = devm_thermal_of_child_cooling_device_register(dev->parent,
[Severity: Medium]
Could this leak the regulator on probe error or driver unbind?
If devm_thermal_of_child_cooling_device_register() fails later in
khadas_mcu_fan_probe(), the function returns without calling
regulator_disable().
Additionally, there is no remove callback in khadas_mcu_fan_driver:
static struct platform_driver khadas_mcu_fan_driver = {
.probe = khadas_mcu_fan_probe,
.shutdown = khadas_mcu_fan_shutdown,
.driver = { ...
This means the regulator is not cleanly disabled when the driver is unbound,
which could leave the reference leaked and prevent the regulator from ever
being powered down.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-add-mcu-fan-khadas-vim4-v9-0-75df78710b9e@aliel.fr?part=5
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-08-05 8:19 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 8:06 [PATCH v9 0/6] Add VIM4 MCU/FAN support Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:06 ` [PATCH v9 1/6] mfd: khadas-mcu: Add per-variant configuration infrastructure and VIM4 support Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:16 ` sashiko-bot
2026-08-05 8:16 ` sashiko-bot
2026-08-05 8:06 ` [PATCH v9 2/6] mfd: khadas-mcu: Use MFD_CELL_* macros for cell declarations Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:16 ` sashiko-bot
2026-08-05 8:16 ` sashiko-bot
2026-08-05 8:06 ` [PATCH v9 3/6] mfd: khadas-mcu: Add support for VIM4 MCU variant Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:19 ` sashiko-bot
2026-08-05 8:19 ` sashiko-bot
2026-08-05 8:06 ` [PATCH v9 4/6] thermal: khadas-mcu-fan: Add fan config from platform data Add regulator support Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:21 ` sashiko-bot
2026-08-05 8:21 ` sashiko-bot
2026-08-07 2:34 ` Daniel Lezcano
2026-08-07 2:34 ` Daniel Lezcano
2026-08-05 8:06 ` [PATCH v9 5/6] arm64: dts: amlogic: t7: Add i2c controller node Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:19 ` sashiko-bot [this message]
2026-08-05 8:19 ` sashiko-bot
2026-08-05 8:06 ` [PATCH v9 6/6] arm64: dts: amlogic: t7: khadas-vim4: Add i2c MCU fan node Ronald Claveau via B4 Relay
2026-08-05 8:06 ` Ronald Claveau
2026-08-05 8:06 ` Ronald Claveau via B4 Relay
2026-08-05 8:24 ` sashiko-bot
2026-08-05 8:24 ` sashiko-bot
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=20260805081910.DBA191F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=lee@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-kernel-dev@aliel.fr \
--cc=mfd@lists.linux.dev \
--cc=neil.armstrong@linaro.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.