public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] ASoC: sma1307: fix uninitialized variable refence
@ 2024-11-13 17:57 Arnd Bergmann
  2024-11-14 15:35 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2024-11-13 17:57 UTC (permalink / raw)
  To: Kiseok Jo, Mark Brown
  Cc: Arnd Bergmann, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Tang Bin, linux-sound, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When firmware loading is disabled, gcc warns that the local
'fw' variable fails to get initialized:

sound/soc/codecs/sma1307.c: In function 'sma1307_setting_loaded.isra':
sound/soc/codecs/sma1307.c:1717:12: error: 'fw' is used uninitialized [-Werror=uninitialized]
 1717 |         if (!fw) {
      |            ^
sound/soc/codecs/sma1307.c:1712:32: note: 'fw' was declared here
 1712 |         const struct firmware *fw;

Check the return code from request_firmware() to ensure that the
firmware is correctly set, and drop the incorrect release_firmware()
on that uninitialized data.

Fixes: 576c57e6b4c1 ("ASoC: sma1307: Add driver for Iron Device SMA1307")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
[v2] check error value correctly
---
 sound/soc/codecs/sma1307.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/codecs/sma1307.c b/sound/soc/codecs/sma1307.c
index 81638768ac12..f2cea6186d98 100644
--- a/sound/soc/codecs/sma1307.c
+++ b/sound/soc/codecs/sma1307.c
@@ -1711,13 +1711,13 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil
 {
 	const struct firmware *fw;
 	int *data, size, offset, num_mode;
+	int ret;
 
-	request_firmware(&fw, file, sma1307->dev);
+	ret = request_firmware(&fw, file, sma1307->dev);
 
-	if (!fw) {
-		dev_err(sma1307->dev, "%s: failed to read \"%s\"\n",
-			__func__, setting_file);
-		release_firmware(fw);
+	if (ret) {
+		dev_err(sma1307->dev, "%s: failed to read \"%s\": %pe\n",
+			__func__, setting_file, ERR_PTR(ret));
 		sma1307->set.status = false;
 		return;
 	} else if ((fw->size) < SMA1307_SETTING_HEADER_SIZE) {
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] [v2] ASoC: sma1307: fix uninitialized variable refence
  2024-11-13 17:57 [PATCH] [v2] ASoC: sma1307: fix uninitialized variable refence Arnd Bergmann
@ 2024-11-14 15:35 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2024-11-14 15:35 UTC (permalink / raw)
  To: Kiseok Jo, Arnd Bergmann
  Cc: Arnd Bergmann, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
	Tang Bin, linux-sound, linux-kernel

On Wed, 13 Nov 2024 18:57:13 +0100, Arnd Bergmann wrote:
> When firmware loading is disabled, gcc warns that the local
> 'fw' variable fails to get initialized:
> 
> sound/soc/codecs/sma1307.c: In function 'sma1307_setting_loaded.isra':
> sound/soc/codecs/sma1307.c:1717:12: error: 'fw' is used uninitialized [-Werror=uninitialized]
>  1717 |         if (!fw) {
>       |            ^
> sound/soc/codecs/sma1307.c:1712:32: note: 'fw' was declared here
>  1712 |         const struct firmware *fw;
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: sma1307: fix uninitialized variable refence
      commit: c48a4497356f701f94f1951626637ae240af909e

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-14 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-13 17:57 [PATCH] [v2] ASoC: sma1307: fix uninitialized variable refence Arnd Bergmann
2024-11-14 15:35 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox