From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Dimitrios Katsaros <patcherwork@gmail.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>,
shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com,
linux-sound@vger.kernel.org
Subject: [PATCH AUTOSEL 6.18-5.10] ASoC: tlv320adcx140: Propagate error codes during probe
Date: Tue, 20 Jan 2026 14:34:46 -0500 [thread overview]
Message-ID: <20260120193456.865383-3-sashal@kernel.org> (raw)
In-Reply-To: <20260120193456.865383-1-sashal@kernel.org>
From: Dimitrios Katsaros <patcherwork@gmail.com>
[ Upstream commit d89aad92cfd15edbd704746f44c98fe687f9366f ]
When scanning for the reset pin, we could get an -EPROBE_DEFER.
The driver would assume that no reset pin had been defined,
which would mean that the chip would never be powered.
Now we both respect any error we get from devm_gpiod_get_optional.
We also now properly report the missing GPIO definition when
'gpio_reset' is NULL.
Signed-off-by: Dimitrios Katsaros <patcherwork@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Link: https://patch.msgid.link/20260113-sound-soc-codecs-tvl320adcx140-v4-3-8f7ecec525c8@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
This confirms my analysis. In `adcx140_reset()`, the code checks `if
(adcx140->gpio_reset)`. An error pointer like `-EPROBE_DEFER` evaluates
to TRUE (non-zero), so if the original code allowed an error pointer to
be stored, this function would try to use an invalid descriptor -
leading to a crash or undefined behavior.
## Analysis Summary
### 1. COMMIT MESSAGE ANALYSIS
- The commit message clearly explains the bug: `-EPROBE_DEFER` was being
swallowed when getting the reset GPIO
- The consequence is that "the chip would never be powered" - this is a
real functionality bug
- The fix properly propagates errors and only logs "missing GPIO" when
the GPIO is actually NULL
### 2. CODE CHANGE ANALYSIS
**The Bug:**
- `devm_gpiod_get_optional()` can return error pointers (e.g.,
`-EPROBE_DEFER`)
- The original code only logged a message when `IS_ERR()` was true, but
continued execution
- If `-EPROBE_DEFER` was returned, the driver would fail silently - the
device would not work properly
- Worse, an error pointer would pass the `if (adcx140->gpio_reset)`
check in `adcx140_reset()`, potentially causing crashes
**The Fix:**
- Properly returns errors from `devm_gpiod_get_optional()` using
`dev_err_probe()`
- `dev_err_probe()` is the modern idiom that handles `-EPROBE_DEFER`
cleanly (doesn't spam logs)
- The informational message is now correctly tied to
`!adcx140->gpio_reset` (GPIO truly not defined)
### 3. CLASSIFICATION
- **Bug fix**: Yes - fixes improper error handling that causes device
malfunction
- **Security**: No
- **New feature**: No - this is correcting existing broken behavior
- **Exception category**: Not a device ID/quirk/DT fix, but a standard
bug fix
### 4. SCOPE AND RISK ASSESSMENT
- **Lines changed**: Only ~4 lines modified
- **Files touched**: 1 file (single audio codec driver)
- **Complexity**: Very low - straightforward error handling fix
- **Risk**: Very low - the change is localized and makes the code behave
correctly
- **Subsystem**: ASoC codec driver (specific hardware, not core
infrastructure)
### 5. USER IMPACT
- **Who is affected**: Users of TLV320ADCx140 family audio codecs (TI
ADCs)
- **Severity**: Without this fix, the device may fail to initialize
properly when GPIO provider isn't ready yet
- **Real-world impact**: The `-EPROBE_DEFER` case is common during early
boot when GPIO controllers aren't yet initialized
### 6. STABILITY INDICATORS
- Has `Signed-off-by` from the patch author and subsystem maintainer
(Mark Brown)
- Standard error handling pattern used in many other drivers
### 7. DEPENDENCY CHECK
- No dependencies on other commits
- The driver has existed since kernel 5.7 (added Feb 2020)
- This fix should apply cleanly to all stable kernels that have this
driver
### Conclusion
This is an **excellent candidate for stable backport** because:
1. It fixes a real bug where `-EPROBE_DEFER` is swallowed, causing
device initialization failure
2. The fix is small, surgical, and obviously correct
3. It uses the modern `dev_err_probe()` pattern that's standard across
the kernel
4. Risk of regression is minimal - it only changes error handling to do
the right thing
5. The bug has existed since the driver was introduced, affecting all
users of this codec
**YES**
sound/soc/codecs/tlv320adcx140.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320adcx140.c
index d594bf166c0e7..bcbc240248342 100644
--- a/sound/soc/codecs/tlv320adcx140.c
+++ b/sound/soc/codecs/tlv320adcx140.c
@@ -1158,6 +1158,9 @@ static int adcx140_i2c_probe(struct i2c_client *i2c)
adcx140->gpio_reset = devm_gpiod_get_optional(adcx140->dev,
"reset", GPIOD_OUT_LOW);
if (IS_ERR(adcx140->gpio_reset))
+ return dev_err_probe(&i2c->dev, PTR_ERR(adcx140->gpio_reset),
+ "Failed to get Reset GPIO\n");
+ if (!adcx140->gpio_reset)
dev_info(&i2c->dev, "Reset GPIO not defined\n");
adcx140->supply_areg = devm_regulator_get_optional(adcx140->dev,
--
2.51.0
next prev parent reply other threads:[~2026-01-20 19:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 19:34 [PATCH AUTOSEL 6.18] ALSA: usb-audio: Prevent excessive number of frames Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18-6.6] ASoC: amd: yc: Fix microphone on ASUS M6500RE Sasha Levin
2026-01-20 19:34 ` Sasha Levin [this message]
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18-6.1] nvme-fc: release admin tagset if init fails Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18] dmaengine: mmp_pdma: Fix race condition in mmp_pdma_residue() Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18-5.10] ASoC: davinci-evm: Fix reference leak in davinci_evm_probe Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18-6.6] nvmet-tcp: fixup hang in nvmet_tcp_listen_data_ready() Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18-6.12] ASoC: simple-card-utils: Check device node before overwrite direction Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18] ASoC: Intel: sof_sdw: Add new quirks for PTL on Dell with CS42L43 Sasha Levin
2026-01-20 19:34 ` [PATCH AUTOSEL 6.18] ALSA: hda/tas2781: Add newly-released HP laptop Sasha Levin
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=20260120193456.865383-3-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=kevin-lu@ti.com \
--cc=linux-sound@vger.kernel.org \
--cc=patcherwork@gmail.com \
--cc=patches@lists.linux.dev \
--cc=s.hauer@pengutronix.de \
--cc=shenghao-ding@ti.com \
--cc=stable@vger.kernel.org \
/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