diff mbox series

ASoC: nau8821: check regmap_raw_read/regmap_raw_write for failure

Message ID 20241018110743.18786-1-v.shevtsov@maxima.ru (mailing list archive)
State Accepted
Commit 1b9971a4e01b80afbf061ad7cdf84ac6fbbbde8d
Headers show
Series ASoC: nau8821: check regmap_raw_read/regmap_raw_write for failure | expand

Commit Message

Vitaliy Shevtsov Oct. 18, 2024, 11:07 a.m. UTC
The return values from both regmap_raw_read() and regmap_raw_write() are not
checked despite they can fail. Propagate possible errors to caller.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Fixes: aab1ad11d69f ("ASoC: nau8821: new driver")
Signed-off-by: Vitaliy Shevtsov <v.shevtsov@maxima.ru>
---
 sound/soc/codecs/nau8821.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Andy Shevchenko Oct. 18, 2024, 11:36 a.m. UTC | #1
On Fri, Oct 18, 2024 at 2:07 PM Vitaliy Shevtsov <v.shevtsov@maxima.ru> wrote:
>
> The return values from both regmap_raw_read() and regmap_raw_write() are not
> checked despite they can fail. Propagate possible errors to caller.

"...them failing."
"...to the caller."

> Found by Linux Verification Center (linuxtesting.org) with Svace.

> Fixes: aab1ad11d69f ("ASoC: nau8821: new driver")

Are you sure?

While the code wise the patch is correct, the behaviour changes may be
catastrophic in some corner cases. The first one is the read where we
try to get the data from the register, that one may be okay, but the
write should be first put into the group of mandatory or optional IO.
If it's the second, why bother with the IO failure?
Mark Brown Oct. 18, 2024, 8:01 p.m. UTC | #2
On Fri, 18 Oct 2024 16:07:41 +0500, Vitaliy Shevtsov wrote:
> The return values from both regmap_raw_read() and regmap_raw_write() are not
> checked despite they can fail. Propagate possible errors to caller.
> 
> Found by Linux Verification Center (linuxtesting.org) with Svace.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: nau8821: check regmap_raw_read/regmap_raw_write for failure
      commit: 1b9971a4e01b80afbf061ad7cdf84ac6fbbbde8d

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
diff mbox series

Patch

diff --git a/sound/soc/codecs/nau8821.c b/sound/soc/codecs/nau8821.c
index de5c4db05c8f..edb95f869a4a 100644
--- a/sound/soc/codecs/nau8821.c
+++ b/sound/soc/codecs/nau8821.c
@@ -287,10 +287,8 @@  static int nau8821_biq_coeff_get(struct snd_kcontrol *kcontrol,
 	if (!component->regmap)
 		return -EINVAL;
 
-	regmap_raw_read(component->regmap, NAU8821_R21_BIQ0_COF1,
+	return regmap_raw_read(component->regmap, NAU8821_R21_BIQ0_COF1,
 		ucontrol->value.bytes.data, params->max);
-
-	return 0;
 }
 
 static int nau8821_biq_coeff_put(struct snd_kcontrol *kcontrol,
@@ -299,6 +297,7 @@  static int nau8821_biq_coeff_put(struct snd_kcontrol *kcontrol,
 	struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
 	struct soc_bytes_ext *params = (void *)kcontrol->private_value;
 	void *data;
+	int ret;
 
 	if (!component->regmap)
 		return -EINVAL;
@@ -308,12 +307,12 @@  static int nau8821_biq_coeff_put(struct snd_kcontrol *kcontrol,
 	if (!data)
 		return -ENOMEM;
 
-	regmap_raw_write(component->regmap, NAU8821_R21_BIQ0_COF1,
+	ret = regmap_raw_write(component->regmap, NAU8821_R21_BIQ0_COF1,
 		data, params->max);
 
 	kfree(data);
 
-	return 0;
+	return ret;
 }
 
 static const char * const nau8821_adc_decimation[] = {