All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vojtěch Krátký" <vo.kratky@seznam.cz>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing
Date: Thu, 04 Jun 2026 12:12:50 +0000	[thread overview]
Message-ID: <20260604121251.2BB881F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260604120201.116925-3-vo.kratky@seznam.cz>

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

Pre-existing issues:
- [High] Direct return on devm_thermal_of_zone_register failure skips critical error cleanup (PM leak and Use-After-Free).
- [High] Unbalanced disable_irq() on sun4i_prepare_for_irq() error path permanently disables the IRQ.
--

commit 4c81144898d1e91a3f1c0bfb6354a6f38c7251b4
Author: Vojtěch Krátký <vo.kratky@seznam.cz>

iio: adc: change from %ld to %pe for PTR_ERR() printing

This commit replaces numeric PTR_ERR() logging with the %pe format specifier.
The goal is to print error values in a more readable form.

> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 479115ea50bf9..5d7a61abcaeae 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c

[ ... ]

> @@ -639,8 +639,8 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  		 */
>  		if (IS_ERR(info->tzd) && PTR_ERR(info->tzd) != -ENODEV) {
>  			dev_err(&pdev->dev,
> -				"could not register thermal sensor: %ld\n",
> -				PTR_ERR(info->tzd));
> +				"could not register thermal sensor: %pe\n",
> +				info->tzd);
>  			return PTR_ERR(info->tzd);

[Severity: High]
This isn't a bug introduced by this patch, but returning directly here
skips the err_map cleanup label.

If devm_thermal_of_zone_register() fails with an error other than -ENODEV,
this code returns directly. Does this leave the device's runtime PM enabled
because the pm_runtime_disable() call in the err_map block is skipped?

Also, if the device was probed via sun4i_gpadc_probe_mfd(),
iio_map_array_register() was successfully called earlier:

drivers/iio/adc/sun4i-gpadc-iio.c:sun4i_gpadc_probe_mfd() {
    ...
    ret = iio_map_array_register(indio_dev, sun4i_gpadc_hwmon_maps);
    ...
}

By skipping iio_map_array_unregister() at the err_map label, does this
leave a dangling pointer in the global IIO maps pointing to indio_dev?
Since indio_dev is managed by devres (devm_iio_device_alloc), its memory
will be freed immediately upon probe failure. Could this result in a
use-after-free when another subsystem attempts to read from the map?

>  		}
>  	}

While reviewing this file, I also noticed another pre-existing regression in
sun4i_gpadc_read().

[Severity: High]
This is a pre-existing issue, but does the unbalanced disable_irq() on the
sun4i_prepare_for_irq() error path permanently disable the IRQ?

drivers/iio/adc/sun4i-gpadc-iio.c:sun4i_gpadc_read() {
    ...
    ret = sun4i_prepare_for_irq(indio_dev, channel, irq);
    if (ret)
        goto err;

    enable_irq(irq);
    ...
err:
    pm_runtime_put_autosuspend(indio_dev->dev.parent);
    disable_irq(irq);
    mutex_unlock(&info->mutex);
}

If sun4i_prepare_for_irq() fails, the code jumps to the err label and
unconditionally executes disable_irq(irq). Because enable_irq(irq) was never
reached, this increases the IRQ disable depth. 

Since the IRQs are initially requested with IRQF_NO_AUTOEN
(initial depth = 1), the unbalanced disable_irq() bumps the depth to 2.
On subsequent successful reads, enable_irq() will only decrement the depth
back to 1. Does this leave the IRQ permanently masked, causing
wait_for_completion_timeout() to continually time out?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260604120201.116925-1-vo.kratky@seznam.cz?part=2

  reply	other threads:[~2026-06-04 12:12 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04 11:59 [PATCH v2 00/11] iio: change from %ld to %pe for PTR_ERR() printing Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 01/11] iio: accel: " Vojtěch Krátký
2026-06-04 12:13   ` Joshua Crofts
2026-06-05 11:57     ` Jonathan Cameron
2026-06-04 11:59 ` [PATCH v2 02/11] iio: adc: " Vojtěch Krátký
2026-06-04 12:12   ` sashiko-bot [this message]
2026-06-13  8:06   ` Jernej Škrabec
2026-06-04 11:59 ` [PATCH v2 03/11] iio: chemical: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 04/11] iio: common: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 05/11] iio: dac: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 06/11] iio: gyro: " Vojtěch Krátký
2026-06-04 20:08   ` Andy Shevchenko
2026-06-04 11:59 ` [PATCH v2 07/11] iio: humidity: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 08/11] iio: imu: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 09/11] iio: light: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 10/11] iio: proximity: " Vojtěch Krátký
2026-06-04 11:59 ` [PATCH v2 11/11] iio: resolver: " Vojtěch Krátký

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=20260604121251.2BB881F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vo.kratky@seznam.cz \
    /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.