2020-04-20 12:15:12

by Jason Yan

[permalink] [raw]
Subject: [PATCH] staging: mt7621-pinctrl: Use correct pointer type argument for sizeof

Fix the following coccicheck warning:

drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:223:14-36: WARNING: Use
correct pointer type argument for sizeof

Signed-off-by: Jason Yan <[email protected]>
---
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
index d0f06790d38f..8883f2a8ea57 100644
--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
+++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
@@ -220,7 +220,7 @@ static int rt2880_pinmux_index(struct rt2880_priv *p)
/* allocate our function and group mapping index buffers */
f = p->func = devm_kcalloc(p->dev,
p->func_count,
- sizeof(struct rt2880_pmx_func),
+ sizeof(struct rt2880_pmx_func *),
GFP_KERNEL);
gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int),
GFP_KERNEL);
--
2.21.1


2020-04-20 12:23:09

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: mt7621-pinctrl: Use correct pointer type argument for sizeof

On Mon, Apr 20, 2020 at 08:37:55PM +0800, Jason Yan wrote:
> Fix the following coccicheck warning:
>
> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:223:14-36: WARNING: Use
> correct pointer type argument for sizeof
>
> Signed-off-by: Jason Yan <[email protected]>
> ---
> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> index d0f06790d38f..8883f2a8ea57 100644
> --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
> @@ -220,7 +220,7 @@ static int rt2880_pinmux_index(struct rt2880_priv *p)
> /* allocate our function and group mapping index buffers */
> f = p->func = devm_kcalloc(p->dev,
> p->func_count,
> - sizeof(struct rt2880_pmx_func),
> + sizeof(struct rt2880_pmx_func *),

Yes. This fixes a bug. We were allocating too much data. But the
prefered style is:

sizeof(*p->func),

Please could you resend?

regards,
dan carpenter

2020-04-20 12:37:33

by Jason Yan

[permalink] [raw]
Subject: Re: [PATCH] staging: mt7621-pinctrl: Use correct pointer type argument for sizeof



?? 2020/4/20 20:19, Dan Carpenter ะด??:
> On Mon, Apr 20, 2020 at 08:37:55PM +0800, Jason Yan wrote:
>> Fix the following coccicheck warning:
>>
>> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:223:14-36: WARNING: Use
>> correct pointer type argument for sizeof
>>
>> Signed-off-by: Jason Yan <[email protected]>
>> ---
>> drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
>> index d0f06790d38f..8883f2a8ea57 100644
>> --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
>> +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
>> @@ -220,7 +220,7 @@ static int rt2880_pinmux_index(struct rt2880_priv *p)
>> /* allocate our function and group mapping index buffers */
>> f = p->func = devm_kcalloc(p->dev,
>> p->func_count,
>> - sizeof(struct rt2880_pmx_func),
>> + sizeof(struct rt2880_pmx_func *),
>
> Yes. This fixes a bug. We were allocating too much data. But the
> prefered style is:
>
> sizeof(*p->func),
>
> Please could you resend?
>

Sure, I will cook a new one.

> regards,
> dan carpenter
>
>
> .
>