From mboxrd@z Thu Jan 1 00:00:00 1970 From: j.neuschaefer@gmx.net (Jonathan =?utf-8?Q?Neusch=C3=A4fer?=) Date: Thu, 23 Jun 2011 20:49:00 +0200 Subject: Is this a Bug? In-Reply-To: <7088ABF5-4E3C-4FA6-BFD0-C163251CCB3D@gmail.com> References: <7088ABF5-4E3C-4FA6-BFD0-C163251CCB3D@gmail.com> Message-ID: <20110623184859.GB10371@debian.debian> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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