[PATCH 0/6] ASOC: Fix the error handling code of the probe
These drivers mishandle the regulator resource in the probe function, failing to disable the regulator for probing failure.
Zheyu Ma (6): ASoC: cs42l52: Fix the error handling of cs42l56_i2c_probe() ASoC: cs35l36: Fix the error handling of cs35l36_i2c_probe() ASoC: rt5645: Fix the error handling of rt5645_i2c_probe() ASoC: tas571x: Fix the error handling of tas571x_i2c_probe() ASoC: tas6424: Fix the error handling of tas6424_i2c_probe() ASoC: wm8903: Fix the error handling of wm8903_i2c_probe()
sound/soc/codecs/cs35l36.c | 2 +- sound/soc/codecs/cs42l56.c | 2 +- sound/soc/codecs/rt5645.c | 4 ++-- sound/soc/codecs/tas571x.c | 6 ++++-- sound/soc/codecs/tas6424.c | 8 ++++++-- sound/soc/codecs/wm8903.c | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-)
The driver should goto label 'err_enable' when failing at regmap_read().
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- sound/soc/codecs/cs42l56.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index 2c4e09b43199..dc23007336c5 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c @@ -1245,7 +1245,7 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client) ret = regmap_read(cs42l56->regmap, CS42L56_CHIP_ID_1, ®); if (ret) { dev_err(&i2c_client->dev, "Failed to read chip ID: %d\n", ret); - return ret; + goto err_enable; }
devid = reg & CS42L56_CHIP_ID_MASK;
On Tue, May 10, 2022 at 11:32:46PM +0800, Zheyu Ma wrote:
The driver should goto label 'err_enable' when failing at regmap_read().
Signed-off-by: Zheyu Ma zheyuma97@gmail.com
sound/soc/codecs/cs42l56.c | 2 +-
Patch looks good but the subject line says cs42l52 instead of 56.
Thanks, Charles
The driver should goto label 'err_enable' when failing at regmap_read().
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- Changes in v2: - Fix the typo in the subject --- sound/soc/codecs/cs42l56.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index 2c4e09b43199..dc23007336c5 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c @@ -1245,7 +1245,7 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client) ret = regmap_read(cs42l56->regmap, CS42L56_CHIP_ID_1, ®); if (ret) { dev_err(&i2c_client->dev, "Failed to read chip ID: %d\n", ret); - return ret; + goto err_enable; }
devid = reg & CS42L56_CHIP_ID_MASK;
On Wed, May 11, 2022 at 09:55:14AM +0800, Zheyu Ma wrote:
The driver should goto label 'err_enable' when failing at regmap_read().
Signed-off-by: Zheyu Ma zheyuma97@gmail.com
Changes in v2: - Fix the typo in the subject
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
The driver should goto label 'err' when failing at regmap_read().
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- sound/soc/codecs/cs35l36.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs35l36.c b/sound/soc/codecs/cs35l36.c index cc5e80222916..920190daa4d1 100644 --- a/sound/soc/codecs/cs35l36.c +++ b/sound/soc/codecs/cs35l36.c @@ -1803,7 +1803,7 @@ static int cs35l36_i2c_probe(struct i2c_client *i2c_client) if (ret < 0) { dev_err(&i2c_client->dev, "Failed to read otp_id Register %d\n", ret); - return ret; + goto err; }
if ((l37_id_reg & CS35L36_OTP_REV_MASK) == CS35L36_OTP_REV_L37)
On Tue, May 10, 2022 at 11:32:47PM +0800, Zheyu Ma wrote:
The driver should goto label 'err' when failing at regmap_read().
Signed-off-by: Zheyu Ma zheyuma97@gmail.com
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
After enabling the regulator, The driver should disable the regulator when failing at probing.
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- sound/soc/codecs/rt5645.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 1518eb7e9201..ccdea234a3ba 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3943,7 +3943,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c) ret = PTR_ERR(regmap); dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n", ret); - return ret; + goto err_enable; }
/* @@ -3974,7 +3974,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c) ret = PTR_ERR(rt5645->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); - return ret; + goto err_enable; }
regmap_write(rt5645->regmap, RT5645_RESET, 0);
After enabling the regulator, The driver should disable the regulator when failing at probing.
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- sound/soc/codecs/tas571x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/tas571x.c b/sound/soc/codecs/tas571x.c index dd289774efb2..7b599664db20 100644 --- a/sound/soc/codecs/tas571x.c +++ b/sound/soc/codecs/tas571x.c @@ -833,7 +833,8 @@ static int tas571x_i2c_probe(struct i2c_client *client) if (IS_ERR(priv->pdn_gpio)) { dev_err(dev, "error requesting pdn_gpio: %ld\n", PTR_ERR(priv->pdn_gpio)); - return PTR_ERR(priv->pdn_gpio); + ret = PTR_ERR(priv->pdn_gpio); + goto disable_regs; }
priv->reset_gpio = devm_gpiod_get_optional(dev, "reset", @@ -841,7 +842,8 @@ static int tas571x_i2c_probe(struct i2c_client *client) if (IS_ERR(priv->reset_gpio)) { dev_err(dev, "error requesting reset_gpio: %ld\n", PTR_ERR(priv->reset_gpio)); - return PTR_ERR(priv->reset_gpio); + ret = PTR_ERR(priv->reset_gpio); + goto disable_regs; } else if (priv->reset_gpio) { /* pulse the active low reset line for ~100us */ usleep_range(100, 200);
After enabling the regulator, The driver should disable the regulator when failing at probing.
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- sound/soc/codecs/tas6424.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/tas6424.c b/sound/soc/codecs/tas6424.c index d87444efed37..22b53856e691 100644 --- a/sound/soc/codecs/tas6424.c +++ b/sound/soc/codecs/tas6424.c @@ -756,7 +756,7 @@ static int tas6424_i2c_probe(struct i2c_client *client) TAS6424_RESET, TAS6424_RESET); if (ret) { dev_err(dev, "unable to reset device: %d\n", ret); - return ret; + goto disable_regs; }
INIT_DELAYED_WORK(&tas6424->fault_check_work, tas6424_fault_check_work); @@ -765,10 +765,14 @@ static int tas6424_i2c_probe(struct i2c_client *client) tas6424_dai, ARRAY_SIZE(tas6424_dai)); if (ret < 0) { dev_err(dev, "unable to register codec: %d\n", ret); - return ret; + goto disable_regs; }
return 0; + +disable_regs: + regulator_bulk_disable(ARRAY_SIZE(tas6424->supplies), tas6424->supplies); + return ret; }
static int tas6424_i2c_remove(struct i2c_client *client)
The driver should goto label 'err' when failing to request the irq.
Signed-off-by: Zheyu Ma zheyuma97@gmail.com --- sound/soc/codecs/wm8903.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index ddcef11dce7c..3c95c2aea515 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -2131,7 +2131,7 @@ static int wm8903_i2c_probe(struct i2c_client *i2c) if (ret != 0) { dev_err(wm8903->dev, "Failed to request IRQ: %d\n", ret); - return ret; + goto err; }
/* Enable write sequencer interrupts */
On Tue, May 10, 2022 at 11:32:51PM +0800, Zheyu Ma wrote:
The driver should goto label 'err' when failing to request the irq.
Signed-off-by: Zheyu Ma zheyuma97@gmail.com
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
On Tue, 10 May 2022 23:32:45 +0800, Zheyu Ma wrote:
These drivers mishandle the regulator resource in the probe function, failing to disable the regulator for probing failure.
Zheyu Ma (6): ASoC: cs42l52: Fix the error handling of cs42l56_i2c_probe() ASoC: cs35l36: Fix the error handling of cs35l36_i2c_probe() ASoC: rt5645: Fix the error handling of rt5645_i2c_probe() ASoC: tas571x: Fix the error handling of tas571x_i2c_probe() ASoC: tas6424: Fix the error handling of tas6424_i2c_probe() ASoC: wm8903: Fix the error handling of wm8903_i2c_probe()
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/6] ASoC: cs42l52: Fix the error handling of cs42l56_i2c_probe() commit: c1ce4ba5021a9730c00bab6f8122702deb69d37e [2/6] ASoC: cs35l36: Fix the error handling of cs35l36_i2c_probe() commit: cf7250e95d309ae518918613fb904a4565ffc85d [3/6] ASoC: rt5645: Fix the error handling of rt5645_i2c_probe() commit: 7883c193d7ae1ccc20ee4c06d2a1fea40074e454 [4/6] ASoC: tas571x: Fix the error handling of tas571x_i2c_probe() commit: ef1878fd0cd61f0f3fafdf518bb8f1df742ef760 [5/6] ASoC: tas6424: Fix the error handling of tas6424_i2c_probe() commit: 68cacb5cf5cf04aaa95be1fd76eff728dfddc613 [6/6] ASoC: wm8903: Fix the error handling of wm8903_i2c_probe() commit: 83d1b65d4cbe6fb0bbdacc18c1f4ad0450275d8f
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (3)
-
Charles Keepax
-
Mark Brown
-
Zheyu Ma