From mboxrd@z Thu Jan 1 00:00:00 1970 From: walter harms Date: Sun, 13 Dec 2009 14:09:16 +0000 Subject: Re: [PATCH 9/9] sound/soc/codecs: Correct code taking the size of Message-Id: <4B24F58C.4050502@bfs.de> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Julia Lawall Cc: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Julia Lawall schrieb: > From: Julia Lawall > > sizeof(codec->reg_cache) is just the size of the pointer. Elsewhere in the > file, codec->reg_cache is used with sizeof(wm8900_reg_defaults), so the > code is changed to do the same here. > > A simplified version of the semantic patch that finds this problem is as > follows: (http://coccinelle.lip6.fr/) > > // > @@ > expression *x; > expression f; > type T; > @@ > > *f(...,(T)x,...) > // > > Signed-off-by: Julia Lawall > > --- > sound/soc/codecs/wm8900.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c > index c9438dd..dbc368c 100644 > --- a/sound/soc/codecs/wm8900.c > +++ b/sound/soc/codecs/wm8900.c > @@ -199,7 +199,7 @@ static void wm8900_reset(struct snd_soc_codec *codec) > snd_soc_write(codec, WM8900_REG_RESET, 0); > > memcpy(codec->reg_cache, wm8900_reg_defaults, > - sizeof(codec->reg_cache)); > + sizeof(wm8900_reg_defaults)); > } I do not think that this was the intention of the original author, I guess the idea behind sizeof(*codec->reg_cache) was to protect the area behind it (in case wm8900_reg_defaults are badly defined). re, wh