| Message ID | 20260906-gpadc-v1-2-92d3dc8ef355@gmail.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-25638-sunxi=pue.re@lists.linux.dev>
X-Original-To: noreply@patchwork.local
Delivered-To: noreply@patchwork.local
Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mxe881.netcup.net (Postfix) with ESMTPS id 3D0BB1C0726
for <noreply@patchwork.local>; Sun, 6 Sep 2026 17:59:13 +0200 (CEST)
Authentication-Results: mxe881;
dkim=pass header.d=gmail.com;
spf=pass (sender IP is 104.64.211.4)
smtp.mailfrom=linux-sunxi+bounces-25638-noreply=patchwork.local@lists.linux.dev
smtp.helo=sin.lore.kernel.org
Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4
as permitted sender) client-ip=104.64.211.4;
envelope-from=linux-sunxi+bounces-25638-noreply=patchwork.local@lists.linux.dev;
helo=sin.lore.kernel.org;
Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org
[100.90.174.1])
by sin.lore.kernel.org (Postfix) with ESMTP id 18201250F7
for <noreply@patchwork.local>; Sun, 6 Sep 2026 15:59:00 +0000 (UTC)
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F66B3AA4E8;
Sun, 6 Sep 2026 15:58:57 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b="nbSdTGyp"
X-Original-To: linux-sunxi@lists.linux.dev
Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com
[209.85.214.178])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FDDB3AA4F1
for <linux-sunxi@lists.linux.dev>; Sun, 6 Sep 2026 15:58:52 +0000 (UTC)
Authentication-Results: smtp.subspace.kernel.org;
arc=none smtp.client-ip=209.85.214.178
ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1788710336; cv=none;
b=bjdmgeINNKgbuPbi0zEWhMJR9p73EiSmA8mzJonItOj9uM63nGX0qYijSrATbB0/ijYFaP61S+dc3qPNJWWUm7OSlIsj2E+ci4x4+fiulQiVFVojLCSxRZTRcxStxeN4JWtkt1YNb3ktZv9zkA9FpuT2/R8DeiY3Gf4EnKpD+yM=
ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1788710336; c=relaxed/simple;
bh=Wt89mC38z1SB+RdqE6/iGje4kTh6KTtVF8QpLkUZBJ8=;
h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References:
In-Reply-To:To:Cc;
b=PR37F7G95avZEaSTKeMCpVzpx2QYdwB4kH/dDxLGFGBdshyZq2Yw7VEJg9NUcOZ65S/I8sjpIUh2t9hWYXpzii1dEK+usULmRhhNMDC8scViQmcFh2RXDJCybyW93rcuN/IznoB/CRNj8WA/YuS72Zf7hJ14MPPWk73bMHXCQDE=
ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com
header.b=nbSdTGyp; arc=none smtp.client-ip=209.85.214.178
Authentication-Results: smtp.subspace.kernel.org;
dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: smtp.subspace.kernel.org;
spf=pass smtp.mailfrom=gmail.com
Received: by mail-pl1-f178.google.com with SMTP id
d9443c01a7336-2cf452def93so31646565ad.1
for <linux-sunxi@lists.linux.dev>;
Sun, 06 Sep 2026 08:58:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1788710330; x=1789315130;
darn=lists.linux.dev;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=F0nEO3AVU8BdN0/yPVQNPwgB0D96TiBKB6Di1KmEt1I=;
b=nbSdTGypt2KyNkAhBSf4mjUvM4SaarPBA6cx2bp/TUcRR6nMpwdBTp1qnK1oHZh81B
r3nZAu4svXbigQ2ywtTJhj2M7OJS81tv0FMtDt2PXhiLSK+aB+hD6oO9rYc98mqpEGMs
IxkGVgcGTYEQwGTi4J5BBIBJneDbKEIHoYqpa9u+FL584G4LTDKco04hkkMIuSGr2sd7
TMrw46oIH0wz+7/D+7J9wIO7chycgVLTE4mzbqSwpWum4o0f996YA9EKbQRSFw3EKK8V
P+3u3+dNRrHs7ePTxdFGR1VfasXvhOTb1KPUgWRYBh2L1MPgxSULd5AmMBY5LhWEz02x
kN0Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1788710330; x=1789315130;
h=cc:to:in-reply-to:references:message-id:content-transfer-encoding
:content-type:mime-version:subject:date:from:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=F0nEO3AVU8BdN0/yPVQNPwgB0D96TiBKB6Di1KmEt1I=;
b=oU1gEqNLM8jvhaPFh7psAElLOubGgnPRuC3sNynA/TIca9QIjQuKbhNP430I8a7CmZ
6fNB+8ZM2rGKc8Ta8/R56iRXGktll8Dff43d1pBYM5FRBsVcDZiT+Co8h0Fn4OGDErxc
z2RjLbr8wshO7pinkcz0+TNUTeirZEggcqcs8+S6evLcTRA3QwQILpIoIPKbRzJZWnUx
nk42q5pfCjREfvCBYf1pdXqOxIcBGDm4x1VeyinOA5s8r4QYkkFXWxjqzQFLDuKFpl+/
UbZY6SqO3UxYXQy8RN4cxELXxnwe35J17x5FeOoH09xRwKjVPfJzeEw8aG669zipXy7u
yx4w==
X-Forwarded-Encrypted: i=1;
AKwUvBwk0u51qoCM9KZ631SEVx1QyndNNhaNjnHlUTuVTYNzJEofwK6A/4XpVVqwqUv8tjw54D4bNyxHVYF2Tw==@lists.linux.dev
X-Gm-Message-State: AFuF++mwRELtKJfugGEh/VLVEaEWsXGQqefgVr2wOTSCcZ6O+qYFxiLX
UZcbP2roDRJ0FVaoNxHm6bN/XFcHmE/dU8jKipGGIfiDJVAFnQKKEBNN
X-Gm-Gg: AYBFou1mGAGw/Jp1dHDJDRaxyAJxMlPte1s/MwwQ7xu89qfUSCslS8wIOggpjQxOuJv
jcWRc4A2E1KCfer8caFtQNM3SmDNZRqeBvG8Ih48rRJ7dNmVwUFqtO4qfRDeBmT4HYu0aFZskH3
tYz4DW+b+5EV2yMMbVhLlaoj4yMeYe/R7Rf6FFETpY0/9gf6+Q36JkUjgqZ2IX39YNLcH9DONKv
OYzvSjG8SQxo9uOSlWRiCNP6ahJJs/AHIoyRl+hEyrf56s5Fk1oIfd9EWlj2gFOY9BA83tPr0zO
qImh2CtU9zCjH84lXYsoDsinpgfENgsqzvss20EKWV4y/dgG86yEYqbQCfDbM13MEoYg74AzsjZ
Wj5bxGg3xuFPkpq8j9rT/glqRdB9rIemX3neHWWgkWlXxmTLZKmgbW/O+Nhms7Mo/5cD6c/vQ+z
ZrGDahltnseb5FVU4gCjU4dRrcXf2lwowhwChRKwtxIHWaJJBQ0MglZIflWhyWIY2dxc9Dg72Za
lDCZhVRq32WdGlcvQip0DeORIYpUBkvNOdzRqg9/9XbKjtCnzvd9JAQ
X-Received: by 2002:a17:90b:5484:b0:384:927f:3db9 with SMTP id
98e67ed59e1d1-39b27c0fa43mr13496195a91.1.1788710329826;
Sun, 06 Sep 2026 08:58:49 -0700 (PDT)
Received: from junjungu-PC.localdomain ([223.166.246.74])
by smtp.gmail.com with ESMTPSA id
98e67ed59e1d1-39b260f64ecsm15941401a91.8.2026.09.06.08.58.45
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 06 Sep 2026 08:58:49 -0700 (PDT)
From: Felix Gu <ustc.gu@gmail.com>
Date: Sun, 06 Sep 2026 23:58:35 +0800
Subject: [PATCH 2/2] iio: adc: sun4i-gpadc-iio: clean up on thermal zone
registration failure
Precedence: bulk
X-Mailing-List: linux-sunxi@lists.linux.dev
List-Id: <linux-sunxi.lists.linux.dev>
List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev>
List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Message-Id: <20260906-gpadc-v1-2-92d3dc8ef355@gmail.com>
References: <20260906-gpadc-v1-0-92d3dc8ef355@gmail.com>
In-Reply-To: <20260906-gpadc-v1-0-92d3dc8ef355@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
=?utf-8?q?Nuno_S=C3=A1?= <nuno.sa@analog.com>,
Andy Shevchenko <andy@kernel.org>, Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Quentin Schulz <quentin.schulz@free-electrons.com>,
Maxime Ripard <mripard@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
Felix Gu <ustc.gu@gmail.com>, Jonathan Cameron <jic23@kernel.org>
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=ed25519-sha256; t=1788710316; l=1124;
i=ustc.gu@gmail.com; h=from:subject:message-id;
bh=Wt89mC38z1SB+RdqE6/iGje4kTh6KTtVF8QpLkUZBJ8=;
b=oha1atVR2mqFYHAgjPpNIY23PNkzfXFXSgJrMheeJEnqaNoYl3svWtK+Ma/SC+uR/OUo2QZH3
3h/DIP34cd5CTKVMzJcWpueUg07gLh1FmVc3T4LYCLOKHZWRSurCtUr
X-Developer-Key: i=ustc.gu@gmail.com; a=ed25519;
pk=fjUXwmjchVN7Ja6KGP55IXOzFeCl9edaHoQIEUA+/hw=
X-Rspamd-Server: rspamd-worker-8404
X-Spamd-Result: default: False [4.34 / 15.00];
RBL_SENDERSCORE(2.00)[104.64.211.4:from];
SUSPICIOUS_RECIPS(1.50)[];
DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed),
No valid DKIM,none];
MAILLIST(-0.15)[generic];
MIME_GOOD(-0.10)[text/plain];
BAD_REP_POLICIES(0.10)[];
HAS_LIST_UNSUB(-0.01)[];
PRECEDENCE_BULK(0.00)[];
RCPT_COUNT_TWELVE(0.00)[15];
FROM_HAS_DN(0.00)[];
DBL_BLOCKED_OPENRESOLVER(0.00)[sin.lore.kernel.org:rdns,sin.lore.kernel.org:helo];
TAGGED_RCPT(0.00)[];
FREEMAIL_CC(0.00)[vger.kernel.org,lists.infradead.org,lists.linux.dev,gmail.com,kernel.org];
FORGED_SENDER_MAILLIST(0.00)[];
RCVD_COUNT_FIVE(0.00)[6];
FROM_NEQ_ENVFROM(0.00)[ustcgu@gmail.com,linux-sunxi@lists.linux.dev];
TAGGED_FROM(0.00)[bounces-25638-noreply=patchwork.local];
R_SPF_ALLOW(0.00)[+ip4:104.64.211.4];
FREEMAIL_TO(0.00)[kernel.org,baylibre.com,analog.com,gmail.com,sholland.org,free-electrons.com];
FREEMAIL_FROM(0.00)[gmail.com];
TO_DN_SOME(0.00)[];
ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG];
FORGED_RECIPIENTS_MAILLIST(0.00)[];
RCVD_TLS_LAST(0.00)[];
MIME_TRACE(0.00)[0:+];
MID_RHS_MATCH_FROM(0.00)[];
ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1];
RCVD_VIA_SMTP_AUTH(0.00)[]
X-Rspamd-Queue-Id: 3D0BB1C0726
X-MORS-Enabled: yes
X-MORS-DOMAIN: patchwork.local
X-MORS-HOSTING: hosting172546
X-MORS-USER: hosting172546
X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?=
|
| Series |
iio: adc: sun4i-gpadc-iio: two fixes
|
|
Commit Message
Felix Gu
Sept. 6, 2026, 3:58 p.m. UTC
If devm_thermal_of_zone_register() fails, probe returns without
unregistering the IIO map array or disabling runtime PM.
Jump to err_map to release them.
Fixes: b0a242894f11 ("iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/iio/adc/sun4i-gpadc-iio.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] pm_runtime_disable() is called manually before devm-managed subsystems are unregistered, exposing a window where callbacks run with runtime PM disabled.
- [High] The driver ignores the return value of pm_runtime_get_sync(), which can lead to accessing hardware registers while the device is suspended or powered off.
--
commit 0cc8a4f7ab93d097709950676951a80ac9c05108
Author: Felix Gu <ustc.gu@gmail.com>
iio: adc: sun4i-gpadc-iio: clean up on thermal zone registration failure
If devm_thermal_of_zone_register() fails, probe returns without
unregistering the IIO map array or disabling runtime PM.
Jump to err_map to release them.
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 85382e435f2a7..ac5ba76b979e6 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -638,10 +638,10 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
> * thermal because no thermal DT node is found.
> */
> 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));
> - return PTR_ERR(info->tzd);
> + ret = dev_err_probe(&pdev->dev,
> + PTR_ERR(info->tzd),
> + "could not register thermal sensor\n");
> + goto err_map;
> }
> }
>
> ret = devm_iio_device_register(&pdev->dev, indio_dev);
> if (ret < 0) {
> dev_err(&pdev->dev, "could not register the device\n");
> goto err_map;
> }
>
> return 0;
>
> err_map:
> if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
> iio_map_array_unregister(indio_dev);
>
> pm_runtime_disable(&pdev->dev);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: High]
This is a pre-existing issue, but does explicitly calling pm_runtime_disable()
here create a window where the devres-managed thermal zone and IIO devices are
still registered while runtime PM is disabled?
Since devm_thermal_of_zone_register() and devm_iio_device_register() are used,
devres will not unregister them until after the probe error path returns.
In the interim, if the thermal core's polling thread invokes .get_temp() or
userspace reads IIO sysfs, could this access hardware while clocks are
disabled, triggering a synchronous external abort?
A similar pre-existing issue appears in sun4i_gpadc_remove():
drivers/iio/adc/sun4i-gpadc-iio.c:sun4i_gpadc_remove() {
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
pm_runtime_disable(&pdev->dev);
...
}
Is pm_runtime_disable() being called here before devres tears down the
registered IIO and thermal zones?
There is another pre-existing issue where return values for
pm_runtime_get_sync() are not checked before accessing hardware. Can this lead
to accessing hardware registers while the device is suspended or powered off?
If pm_runtime_get_sync() fails (e.g., due to runtime PM being disabled during
the teardown race from err_map or remove, or a genuine PM failure), it returns
a negative error code but regmap accesses proceed anyway:
drivers/iio/adc/sun4i-gpadc-iio.c:sun4i_prepare_for_irq() {
...
pm_runtime_get_sync(indio_dev->dev.parent);
reinit_completion(&info->completion);
ret = regmap_write(info->regmap, SUN4I_GPADC_INT_FIFOC,
...
}
And also in sun4i_gpadc_temp_read():
drivers/iio/adc/sun4i-gpadc-iio.c:sun4i_gpadc_temp_read() {
struct sun4i_gpadc_iio *info = iio_priv(indio_dev);
if (info->no_irq) {
pm_runtime_get_sync(indio_dev->dev.parent);
regmap_read(info->regmap, SUN4I_GPADC_TEMP_DATA, val);
...
}
Should the return value of pm_runtime_get_sync() be checked to avoid a bus
fault or kernel panic when reading or writing to unpowered MMIO registers?
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 85382e435f2a..ac5ba76b979e 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -638,10 +638,10 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) * thermal because no thermal DT node is found. */ 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)); - return PTR_ERR(info->tzd); + ret = dev_err_probe(&pdev->dev, + PTR_ERR(info->tzd), + "could not register thermal sensor\n"); + goto err_map; } }