* [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing [not found] <20260604120201.116925-1-vo.kratky@seznam.cz> @ 2026-06-04 11:59 ` Vojtěch Krátký 2026-06-04 12:12 ` sashiko-bot 2026-06-13 8:06 ` Jernej Škrabec 0 siblings, 2 replies; 3+ messages in thread From: Vojtěch Krátký @ 2026-06-04 11:59 UTC (permalink / raw) To: linux-iio Cc: Vojtěch Krátký, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Chen-Yu Tsai, Jernej Skrabec, Samuel Holland, Sakari Ailus, Linus Walleij, Wolfram Sang, linux-arm-kernel, linux-sunxi, linux-kernel Replace numeric PTR_ERR() logging with the %pe format specifier so that error values are printed in a more readable form. This change was identified using a Coccinelle semantic patch. No functional change intended. Signed-off-by: Vojtěch Krátký <vo.kratky@seznam.cz> --- drivers/iio/adc/sun4i-gpadc-iio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 479115ea50bf..5d7a61abcaea 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -508,7 +508,7 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, &sun4i_gpadc_regmap_config); if (IS_ERR(info->regmap)) { ret = PTR_ERR(info->regmap); - dev_err(&pdev->dev, "failed to init regmap: %d\n", ret); + dev_err(&pdev->dev, "failed to init regmap: %pe\n", info->regmap); return ret; } @@ -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); } } -- 2.54.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing 2026-06-04 11:59 ` [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing Vojtěch Krátký @ 2026-06-04 12:12 ` sashiko-bot 2026-06-13 8:06 ` Jernej Škrabec 1 sibling, 0 replies; 3+ messages in thread From: sashiko-bot @ 2026-06-04 12:12 UTC (permalink / raw) To: Vojtěch Krátký; +Cc: linux-sunxi 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing 2026-06-04 11:59 ` [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing Vojtěch Krátký 2026-06-04 12:12 ` sashiko-bot @ 2026-06-13 8:06 ` Jernej Škrabec 1 sibling, 0 replies; 3+ messages in thread From: Jernej Škrabec @ 2026-06-13 8:06 UTC (permalink / raw) To: linux-iio, Vojtěch Krátký Cc: Vojtěch Krátký, Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Chen-Yu Tsai, Samuel Holland, Sakari Ailus, Linus Walleij, Wolfram Sang, linux-arm-kernel, linux-sunxi, linux-kernel Dne četrtek, 4. junij 2026 ob 13:59:22 Srednjeevropski poletni čas je Vojtěch Krátký napisal(a): > Replace numeric PTR_ERR() logging with the %pe format specifier > so that error values are printed in a more readable form. > > This change was identified using a Coccinelle semantic patch. > > No functional change intended. > > Signed-off-by: Vojtěch Krátký <vo.kratky@seznam.cz> Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> Best regards, Jernej ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-13 8:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260604120201.116925-1-vo.kratky@seznam.cz>
2026-06-04 11:59 ` [PATCH v2 02/11] iio: adc: change from %ld to %pe for PTR_ERR() printing Vojtěch Krátký
2026-06-04 12:12 ` sashiko-bot
2026-06-13 8:06 ` Jernej Škrabec
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox