2013-03-13 19:01:09

by Alexandru Gheorghiu

[permalink] [raw]
Subject: [PATCH] arch: s390: net: Replaced kmalloc and memset with kzalloc

Used kzalloc instead of kmalloc followed by memset with 0.
Patch found using coccinelle.

Signed-off-by: Alexandru Gheorghiu <[email protected]>
---
arch/s390/net/bpf_jit_comp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index 0972e91..e645528 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -747,10 +747,9 @@ void bpf_jit_compile(struct sk_filter *fp)

if (!bpf_jit_enable)
return;
- addrs = kmalloc(fp->len * sizeof(*addrs), GFP_KERNEL);
+ addrs = kzalloc(fp->len * sizeof(*addrs), GFP_KERNEL);
if (addrs == NULL)
return;
- memset(addrs, 0, fp->len * sizeof(*addrs));
memset(&jit, 0, sizeof(cjit));
memset(&cjit, 0, sizeof(cjit));

--
1.7.9.5


2013-03-14 07:25:11

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH] arch: s390: net: Replaced kmalloc and memset with kzalloc

On Wed, Mar 13, 2013 at 08:59:17PM +0200, Alexandru Gheorghiu wrote:
> Used kzalloc instead of kmalloc followed by memset with 0.
> Patch found using coccinelle.
>
> Signed-off-by: Alexandru Gheorghiu <[email protected]>
> ---
> arch/s390/net/bpf_jit_comp.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
> index 0972e91..e645528 100644
> --- a/arch/s390/net/bpf_jit_comp.c
> +++ b/arch/s390/net/bpf_jit_comp.c
> @@ -747,10 +747,9 @@ void bpf_jit_compile(struct sk_filter *fp)
>
> if (!bpf_jit_enable)
> return;
> - addrs = kmalloc(fp->len * sizeof(*addrs), GFP_KERNEL);
> + addrs = kzalloc(fp->len * sizeof(*addrs), GFP_KERNEL);
> if (addrs == NULL)
> return;
> - memset(addrs, 0, fp->len * sizeof(*addrs));

We have already a different patch from Stelian Nirlu for the same stuff.