2020-09-09 19:04:11

by Alex Dewar

[permalink] [raw]
Subject: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
this pattern.

Issue identified with Coccinelle.

Signed-off-by: Alex Dewar <[email protected]>
---
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
index 52f5c5a2ed64..7e9a62ad56e8 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
@@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
};
int i;

- dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
+ dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
if (!dsi->debugfs_vpg)
return;

- memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
-
for (i = 0; i < ARRAY_SIZE(debugfs); i++)
debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
dsi->debugfs, &dsi->debugfs_vpg[i],
--
2.28.0


2020-09-11 17:32:26

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

On 09/09/2020 21:02, Alex Dewar wrote:
> kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
> this pattern.
>
> Issue identified with Coccinelle.
>
> Signed-off-by: Alex Dewar <[email protected]>
> ---
> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> index 52f5c5a2ed64..7e9a62ad56e8 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> @@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
> };
> int i;
>
> - dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> + dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
> if (!dsi->debugfs_vpg)
> return;
>
> - memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> -
> for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> dsi->debugfs, &dsi->debugfs_vpg[i],
>

Acked-by: Neil Armstrong <[email protected]>

Thanks,
Neil

2020-09-19 19:33:43

by Alex Dewar

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

On 2020-09-11 13:57, Neil Armstrong wrote:
> On 09/09/2020 21:02, Alex Dewar wrote:
>> kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
>> this pattern.
Friendly ping?
>>
>> Issue identified with Coccinelle.
>>
>> Signed-off-by: Alex Dewar <[email protected]>
>> ---
>> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>> index 52f5c5a2ed64..7e9a62ad56e8 100644
>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>> @@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
>> };
>> int i;
>>
>> - dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>> + dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
>> if (!dsi->debugfs_vpg)
>> return;
>>
>> - memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>> -
>> for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>> debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>> dsi->debugfs, &dsi->debugfs_vpg[i],
>>
> Acked-by: Neil Armstrong <[email protected]>
>
> Thanks,
> Neil

2020-09-20 08:29:03

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

On Sat, Sep 19, 2020 at 9:31 PM Alex Dewar <[email protected]> wrote:
>
> On 2020-09-11 13:57, Neil Armstrong wrote:
> > On 09/09/2020 21:02, Alex Dewar wrote:
> >> kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
> >> this pattern.
> Friendly ping?
> >>
> >> Issue identified with Coccinelle.
> >>
> >> Signed-off-by: Alex Dewar <[email protected]>
> >> ---
> >> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
> >> 1 file changed, 1 insertion(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >> index 52f5c5a2ed64..7e9a62ad56e8 100644
> >> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
> >> @@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
> >> };
> >> int i;
> >>
> >> - dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
> >> + dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
> >> if (!dsi->debugfs_vpg)
> >> return;
> >>
> >> - memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
> >> -
> >> for (i = 0; i < ARRAY_SIZE(debugfs); i++)
> >> debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
> >> dsi->debugfs, &dsi->debugfs_vpg[i],
> >>
> > Acked-by: Neil Armstrong <[email protected]>

Neil has commit rights, so I was assuming he'd push this to drm-misc-next.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

2020-09-21 09:59:43

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

On 20/09/2020 10:24, Daniel Vetter wrote:
> On Sat, Sep 19, 2020 at 9:31 PM Alex Dewar <[email protected]> wrote:
>>
>> On 2020-09-11 13:57, Neil Armstrong wrote:
>>> On 09/09/2020 21:02, Alex Dewar wrote:
>>>> kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
>>>> this pattern.
>> Friendly ping?
>>>>
>>>> Issue identified with Coccinelle.
>>>>
>>>> Signed-off-by: Alex Dewar <[email protected]>
>>>> ---
>>>> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
>>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>>> index 52f5c5a2ed64..7e9a62ad56e8 100644
>>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>>> @@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
>>>> };
>>>> int i;
>>>>
>>>> - dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>>> + dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
>>>> if (!dsi->debugfs_vpg)
>>>> return;
>>>>
>>>> - memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>>> -
>>>> for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>>> debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>>> dsi->debugfs, &dsi->debugfs_vpg[i],
>>>>
>>> Acked-by: Neil Armstrong <[email protected]>
>
> Neil has commit rights, so I was assuming he'd push this to drm-misc-next.
> -Daniel
>

Applying now,
Neil

2020-09-21 10:03:06

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

On 20/09/2020 10:24, Daniel Vetter wrote:
> On Sat, Sep 19, 2020 at 9:31 PM Alex Dewar <[email protected]> wrote:
>>
>> On 2020-09-11 13:57, Neil Armstrong wrote:
>>> On 09/09/2020 21:02, Alex Dewar wrote:
>>>> kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
>>>> this pattern.
>> Friendly ping?
>>>>
>>>> Issue identified with Coccinelle.
>>>>
>>>> Signed-off-by: Alex Dewar <[email protected]>
>>>> ---
>>>> drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 4 +---
>>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>>> index 52f5c5a2ed64..7e9a62ad56e8 100644
>>>> --- a/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c
>>>> @@ -1049,12 +1049,10 @@ static void debugfs_create_files(void *data)
>>>> };
>>>> int i;
>>>>
>>>> - dsi->debugfs_vpg = kmalloc(sizeof(debugfs), GFP_KERNEL);
>>>> + dsi->debugfs_vpg = kmemdup(debugfs, sizeof(debugfs), GFP_KERNEL);
>>>> if (!dsi->debugfs_vpg)
>>>> return;
>>>>
>>>> - memcpy(dsi->debugfs_vpg, debugfs, sizeof(debugfs));
>>>> -
>>>> for (i = 0; i < ARRAY_SIZE(debugfs); i++)
>>>> debugfs_create_file(dsi->debugfs_vpg[i].name, 0644,
>>>> dsi->debugfs, &dsi->debugfs_vpg[i],
>>>>
>>> Acked-by: Neil Armstrong <[email protected]>
>
> Neil has commit rights, so I was assuming he'd push this to drm-misc-next.
> -Daniel
>

Hmm, I applied this already:
commit 33f290811d4c1a09c4e92f5bf0458525835dbcba
Author: Alex Dewar <[email protected]>
Date: Wed Sep 9 20:02:08 2020 +0100

drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy

kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
this pattern.

Issue identified with Coccinelle.

Signed-off-by: Alex Dewar <[email protected]>
Acked-by: Neil Armstrong <[email protected]>
Signed-off-by: Neil Armstrong <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]

Neil

2020-09-21 10:15:03

by Alex Dewar

[permalink] [raw]
Subject: Re: [PATCH] drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy


> Hmm, I applied this already:
> commit 33f290811d4c1a09c4e92f5bf0458525835dbcba
> Author: Alex Dewar <[email protected]>
> Date: Wed Sep 9 20:02:08 2020 +0100
>
> drm/bridge: dw-mipi-dsi: Use kmemdup cf. kmalloc+memcpy
>
> kmemdup can be used instead of kmalloc+memcpy. Replace an occurrence of
> this pattern.
>
> Issue identified with Coccinelle.
>
> Signed-off-by: Alex Dewar <[email protected]>
> Acked-by: Neil Armstrong <[email protected]>
> Signed-off-by: Neil Armstrong <[email protected]>
> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
>
> Neil
Sorry! My bad. Thanks for applying :)

Alex