Thread (8 messages) 8 messages, 5 authors, 2011-06-23

Is this a Bug?

From: j.neuschaefer@gmx.net (Jonathan Neuschäfer)
Date: 2011-06-23 18:49:00
Subsystem: sound, sound - soc layer / dynamic audio power management (asoc), the rest, wolfson microelectronics drivers · Maintainers: Jaroslav Kysela, Takashi Iwai, Liam Girdwood, Mark Brown, Linus Torvalds

On Tue, Jun 21, 2011 at 11:57:02PM +0200, Christian Deussen wrote:
Hi,
I just compiled my first Kernel from linus' tree and saw a warning in "sound/soc/codecs/wm8958-dsp2.c".
I think a found a bug, but I am not sure. And I don`t want to waste the Kernel-dev's time on the lkml. 
In function wm8958_dsp2_fw(), at line 64, there is an uninitialized variable used.


u32 data 32;
  ...
 /*not related code*/
...

	if (memcmp(fw->data, "WMFW", 4) != 0) {
		dev_err(codec->dev, "%s: firmware has bad file magic %08x\n",
			name, data32); //shouldn't fw->data be used?
		goto err;
	}
Unfortunately, printk("%08x", fw->data) will print 32 bit of the pointer
fw->data, not the first 4 bytes of where it points. (CMIIW).

One (somewhat unelegant) solution would be:
	 dev_err(codec->dev, "%s: firmware has bad file magic %02x%02x%02x%02x\n",
			 name, fw->data[0], fw->data[1], fw->data[2], fw->data[3]);


Maybe a fix like this would be appropriate:
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 0293763..9d92de5 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -59,6 +59,9 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
 		goto err;
 	}
 
+	memcpy(&data32, fw->data, sizeof(data32));
+	data32 = be32_to_cpu(data32);
+
 	if (memcmp(fw->data, "WMFW", 4) != 0) {
 		dev_err(codec->dev, "%s: firmware has bad file magic %08x\n",
 			name, data32);
HTH,
	Jonathan Neusch?fer
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help