Skip to contentSkip to conversation

s390: replace kmalloc + memset with kzalloc

PATCH In review Stelian Nirlu 3 participants 4 messages Mar 10, 2013 – Mar 11, 2013 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: replace kmalloc + memset with kzalloc

---
 arch/s390/net/bpf_jit_comp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/net/bpf_jit_comp.c +1 -2
index 0972e91..e645528 100644
@@ -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));
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 10 lines · Stelian Nirlu
---
 arch/s390/net/bpf_jit_comp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/net/bpf_jit_comp.c +0 -0
index 0972e91..e645528 100644

arch/s390/net/bpf_jit_comp.c void bpf_jit_compile(struct sk_filter *fp) · line 750

Quoted 5 lines
arch/s390/net/bpf_jit_comp.c +1 -1
@@ -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);

kcalloc() might be more appropriate here to protect against integer overflow if "fp->len" is too large.

#2 lore raw
Quoted 12 lines · Pekka Enberg
Quoted 11 lines · Stelian Nirlu
---
 arch/s390/net/bpf_jit_comp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/net/bpf_jit_comp.c +0 -0
index 0972e91..e645528 100644
@@ -747,10 +747,9 @@ void bpf_jit_compile(struct sk_filter *fp)
 
Quoted 7 lines

arch/s390/net/bpf_jit_comp.c void bpf_jit_compile(struct sk_filter *fp) · line 750

Quoted 4 lines
arch/s390/net/bpf_jit_comp.c +1 -1
        if (!bpf_jit_enable)
                return;
-       addrs = kmalloc(fp->len * sizeof(*addrs), GFP_KERNEL);
+       addrs = kzalloc(fp->len * sizeof(*addrs), GFP_KERNEL);

kcalloc() might be more appropriate here to protect against integer overflow if "fp->len" is too large.

Stelian, care to send an updated patch which uses kcalloc() instead of kzalloc()?

A message that is not in the archive (sent off-list or not yet received): CACtXKtSzv666_FCHpVm0EkyW=c32kQA9o9-zDqVtJcFYk9mHqQ@mail.gmail.com

#4 lore raw
Quoted 27 lines · Stelian Nirlu
Quoted 24 lines · Heiko Carstens
Quoted 21 lines · Pekka Enberg
Quoted 11 lines · Stelian Nirlu
---
 arch/s390/net/bpf_jit_comp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/s390/net/bpf_jit_comp.c +0 -0
index 0972e91..e645528 100644

arch/s390/net/bpf_jit_comp.c void bpf_jit_compile(struct sk_filter *fp) · line 750

Quoted 5 lines
arch/s390/net/bpf_jit_comp.c +1 -1
@@ -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);

kcalloc() might be more appropriate here to protect against integer overflow if "fp->len" is too large.

Quoted 8 lines
Quoted 3 lines

Stelian, care to send an updated patch which uses kcalloc() instead of kzalloc()?

Yes, sure, I will send the updated patch as soon as possible.

Thank you,
Stelian

I've sent the updated patch.
Mail subject: [PATCH v2] s390: use kcalloc instead of kmalloc and memset