2018-11-27 12:37:31

by Wen Yang

[permalink] [raw]
Subject: [PATCH] Fix invalid use of sizeof in stm32_sai_add_mclk_provider()

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 <[email protected]>
CC: Olivier Moysan <[email protected]>
CC: Arnaud Pouliquen <[email protected]>
CC: Liam Girdwood <[email protected]>
CC: Jaroslav Kysela <[email protected]>
CC: Takashi Iwai <[email protected]>
CC: Maxime Coquelin <[email protected]>
CC: Alexandre Torgue <[email protected]>
CC: Julia Lawall <[email protected]>
CC: Wen Yang <[email protected]>
CC: [email protected]
CC: [email protected]
---
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



2018-11-28 12:40:15

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] Fix invalid use of sizeof in stm32_sai_add_mclk_provider()

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.


Attachments:
(No filename) (362.00 B)
signature.asc (499.00 B)
Download all attachments