linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix invalid use of sizeof in stm32_sai_add_mclk_provider()
@ 2018-11-27 12:35 Wen Yang
  2018-11-28 12:38 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Wen Yang @ 2018-11-27 12:35 UTC (permalink / raw)
  To: olivier.moysan, arnaud.pouliquen, broonie, tiwai, mcoquelin.stm32
  Cc: linux-kernel, zhong.weidong, Wen Yang, Liam Girdwood,
	Jaroslav Kysela, Alexandre Torgue, Julia Lawall, Wen Yang,
	linux-stm32

sizeof(mclk) is 4 or 8 as it is the size of a pointer,
but we want to reserve space for the pointed data.
This issue was detected by using the Coccinelle software.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
CC: Olivier Moysan <olivier.moysan@st.com>
CC: Arnaud Pouliquen <arnaud.pouliquen@st.com>
CC: Liam Girdwood <lgirdwood@gmail.com>
CC: Jaroslav Kysela <perex@perex.cz>
CC: Takashi Iwai <tiwai@suse.com>
CC: Maxime Coquelin <mcoquelin.stm32@gmail.com>
CC: Alexandre Torgue <alexandre.torgue@st.com>
CC: Julia Lawall <julia.lawall@lip6.fr>
CC: Wen Yang <yellowriver2010@hotmail.com>
CC: linux-stm32@st-md-mailman.stormreply.com
CC: linux-kernel@vger.kernel.org
---
 sound/soc/stm/stm32_sai_sub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index ea05cc91aa05..211589b0b2ef 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -390,7 +390,7 @@ static int stm32_sai_add_mclk_provider(struct stm32_sai_sub_data *sai)
 	char *mclk_name, *p, *s = (char *)pname;
 	int ret, i = 0;
 
-	mclk = devm_kzalloc(dev, sizeof(mclk), GFP_KERNEL);
+	mclk = devm_kzalloc(dev, sizeof(*mclk), GFP_KERNEL);
 	if (!mclk)
 		return -ENOMEM;
 
-- 
2.19.1


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

* Re: [PATCH] Fix invalid use of sizeof in stm32_sai_add_mclk_provider()
  2018-11-27 12:35 [PATCH] Fix invalid use of sizeof in stm32_sai_add_mclk_provider() Wen Yang
@ 2018-11-28 12:38 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2018-11-28 12:38 UTC (permalink / raw)
  To: Wen Yang
  Cc: olivier.moysan, arnaud.pouliquen, tiwai, mcoquelin.stm32,
	linux-kernel, zhong.weidong, Liam Girdwood, Jaroslav Kysela,
	Alexandre Torgue, Julia Lawall, Wen Yang, linux-stm32

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

On Tue, Nov 27, 2018 at 08:35:20PM +0800, Wen Yang wrote:
> sizeof(mclk) is 4 or 8 as it is the size of a pointer,
> but we want to reserve space for the pointed data.
> This issue was detected by using the Coccinelle software.

Please use subject lines matching the style for the subsystem.  This
makes it easier for people to identify relevant patches.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2018-11-28 12:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27 12:35 [PATCH] Fix invalid use of sizeof in stm32_sai_add_mclk_provider() Wen Yang
2018-11-28 12:38 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).