Skip to contentSkip to conversation

ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly

PATCH In review Takashi Iwai 3 participants 4 messages May 7, 2019 – May 8, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly

This fixes a compile warning below by properly handling the error code
from sof_get_ctrl_copy_params():
include/linux/kernel.h:843:43: warning: 'sparams.pl_size' may be used uninitialized in this function [-Wmaybe-uninitialized] sound/soc/sof/ipc.c:639:34: note: 'sparams.pl_size' was declared here

The function returns an error before setting sparams.pl_size, so it'd assign an uninitialized value at a later point.

Fixes 53e0c72d98ba ("ASoC: SOF: Add support for IPC IO between DSP and Host")
---
 sound/soc/sof/ipc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/sof/ipc.c +7 -3
index ba1bb17a8d1e..f0b9d3c53f6f 100644
@@ -567,7 +567,7 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
 	size_t offset = 0;
 	size_t msg_bytes;
 	size_t pl_size;
-	int err = 0;
+	int err;
 	int i;
 
 	/* allocate max ipc size because we have at least one */
@@ -576,9 +576,13 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
 		return -ENOMEM;
 
 	if (send)
-		sof_get_ctrl_copy_params(cdata->type, cdata, partdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, cdata, partdata,
+					       sparams);
 	else
-		sof_get_ctrl_copy_params(cdata->type, partdata, cdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
+					       sparams);
+	if (err < 0)
+		return err;
 
 	msg_bytes = sparams->msg_bytes;
 	pl_size = sparams->pl_size;
Signature · 1 line
2.16.4
#1 lore raw
Quoted 7 lines · Takashi Iwai

This fixes a compile warning below by properly handling the error code
from sof_get_ctrl_copy_params():
include/linux/kernel.h:843:43: warning: 'sparams.pl_size' may be used uninitialized in this function [-Wmaybe-uninitialized] sound/soc/sof/ipc.c:639:34: note: 'sparams.pl_size' was declared here

The function returns an error before setting sparams.pl_size, so it'd assign an uninitialized value at a later point.

Thanks Takashi.

I don't recall having seen this warning and this code has been around for a while. Does this show with a special config/compiler?

Adding Jaska since he wrote the support for large control data.

Quoted 37 lines
Fixes 53e0c72d98ba ("ASoC: SOF: Add support for IPC IO between DSP and Host")
---
  sound/soc/sof/ipc.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/sof/ipc.c +7 -3
index ba1bb17a8d1e..f0b9d3c53f6f 100644
@@ -567,7 +567,7 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
  	size_t offset = 0;
  	size_t msg_bytes;
  	size_t pl_size;
-	int err = 0;
+	int err;
  	int i;
 
  	/* allocate max ipc size because we have at least one */
@@ -576,9 +576,13 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
  		return -ENOMEM;
 
  	if (send)
-		sof_get_ctrl_copy_params(cdata->type, cdata, partdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, cdata, partdata,
+					       sparams);
  	else
-		sof_get_ctrl_copy_params(cdata->type, partdata, cdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
+					       sparams);
+	if (err < 0)
+		return err;
 
  	msg_bytes = sparams->msg_bytes;
  	pl_size = sparams->pl_size;
#2 lore raw
Quoted 9 lines · Pierre-Louis Bossart
Quoted 5 lines · Takashi Iwai

This fixes a compile warning below by properly handling the error code
from sof_get_ctrl_copy_params():
include/linux/kernel.h:843:43: warning: 'sparams.pl_size' may be used uninitialized in this function [-Wmaybe-uninitialized] sound/soc/sof/ipc.c:639:34: note: 'sparams.pl_size' was declared here

Quoted 7 lines
Quoted 2 lines

The function returns an error before setting sparams.pl_size, so it'd assign an uninitialized value at a later point.

Thanks Takashi.

I don't recall having seen this warning and this code has been around for a while. Does this show with a special config/compiler?

I got this by a few cross-compilations (e.g. arm64), so it might be specific to some configs, yes.

Takashi

Quoted 38 lines

Adding Jaska since he wrote the support for large control data.

Quoted 34 lines
Fixes 53e0c72d98ba ("ASoC: SOF: Add support for IPC IO between DSP and Host")
---
  sound/soc/sof/ipc.c | 10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/sof/ipc.c +7 -3
index ba1bb17a8d1e..f0b9d3c53f6f 100644
@@ -567,7 +567,7 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
  	size_t offset = 0;
  	size_t msg_bytes;
  	size_t pl_size;
-	int err = 0;
+	int err;
  	int i;
    	/* allocate max ipc size because we have at least one */
@@ -576,9 +576,13 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
  		return -ENOMEM;
    	if (send)
-		sof_get_ctrl_copy_params(cdata->type, cdata, partdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, cdata, partdata,
+					       sparams);
  	else
-		sof_get_ctrl_copy_params(cdata->type, partdata, cdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
+					       sparams);
+	if (err < 0)
+		return err;
    	msg_bytes = sparams->msg_bytes;
  	pl_size = sparams->pl_size;
 
maintainer
#3 lore raw

Applied "ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly" to the asoc tree

In reply to Takashi Iwai

The patch

ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly

has been applied to the asoc tree at

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

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

Quoted 1 line

From 54d198d5019dd98b9bcb9099a389608d7e2cccad Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Tue, 7 May 2019 21:39:10 +0200
Subject: [PATCH] ASoC: SOF: Propagate sof_get_ctrl_copy_params() error
properly

This fixes a compile warning below by properly handling the error code
from sof_get_ctrl_copy_params():
include/linux/kernel.h:843:43: warning: 'sparams.pl_size' may be used uninitialized in this function [-Wmaybe-uninitialized] sound/soc/sof/ipc.c:639:34: note: 'sparams.pl_size' was declared here

The function returns an error before setting sparams.pl_size, so it'd assign an uninitialized value at a later point.

Fixes 53e0c72d98ba ("ASoC: SOF: Add support for IPC IO between DSP and Host")
---
 sound/soc/sof/ipc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/sof/ipc.c +7 -3
index ba1bb17a8d1e..f0b9d3c53f6f 100644
@@ -567,7 +567,7 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
 	size_t offset = 0;
 	size_t msg_bytes;
 	size_t pl_size;
-	int err = 0;
+	int err;
 	int i;
 
 	/* allocate max ipc size because we have at least one */
@@ -576,9 +576,13 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
 		return -ENOMEM;
 
 	if (send)
-		sof_get_ctrl_copy_params(cdata->type, cdata, partdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, cdata, partdata,
+					       sparams);
 	else
-		sof_get_ctrl_copy_params(cdata->type, partdata, cdata, sparams);
+		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
+					       sparams);
+	if (err < 0)
+		return err;
 
 	msg_bytes = sparams->msg_bytes;
 	pl_size = sparams->pl_size;
Signature · 1 line
2.20.1