* [PATCH] staging/rtl8192e: replace kmalloc with kzalloc
@ 2020-10-23 10:03 Elena Afanasova
2020-10-23 10:30 ` [Outreachy kernel] " Julia Lawall
2020-10-23 11:58 ` Matthew Wilcox
0 siblings, 2 replies; 3+ messages in thread
From: Elena Afanasova @ 2020-10-23 10:03 UTC (permalink / raw)
To: gregkh; +Cc: devel, outreachy-kernel, Elena Afanasova
kmalloc() and memset() calls can be replaced with kzalloc().
Found with Coccinelle.
Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
---
drivers/staging/rtl8192e/rtllib_tx.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index e0d79daca24a..c9959bb4ab63 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -205,12 +205,10 @@ static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size,
struct rtllib_txb *txb;
int i;
- txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags),
- gfp_mask);
+ txb = kzalloc(sizeof(*txb) + (sizeof(u8 *) * nr_frags), gfp_mask);
if (!txb)
return NULL;
- memset(txb, 0, sizeof(struct rtllib_txb));
txb->nr_frags = nr_frags;
txb->frag_size = cpu_to_le16(txb_size);
--
2.25.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging/rtl8192e: replace kmalloc with kzalloc
2020-10-23 10:03 [PATCH] staging/rtl8192e: replace kmalloc with kzalloc Elena Afanasova
@ 2020-10-23 10:30 ` Julia Lawall
2020-10-23 11:58 ` Matthew Wilcox
1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2020-10-23 10:30 UTC (permalink / raw)
To: Elena Afanasova; +Cc: devel, gregkh, outreachy-kernel
On Fri, 23 Oct 2020, Elena Afanasova wrote:
> kmalloc() and memset() calls can be replaced with kzalloc().
It would be nice to say why the change is correct.
julia
> Found with Coccinelle.
>
> Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
> ---
> drivers/staging/rtl8192e/rtllib_tx.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
> index e0d79daca24a..c9959bb4ab63 100644
> --- a/drivers/staging/rtl8192e/rtllib_tx.c
> +++ b/drivers/staging/rtl8192e/rtllib_tx.c
> @@ -205,12 +205,10 @@ static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size,
> struct rtllib_txb *txb;
> int i;
>
> - txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags),
> - gfp_mask);
> + txb = kzalloc(sizeof(*txb) + (sizeof(u8 *) * nr_frags), gfp_mask);
> if (!txb)
> return NULL;
>
> - memset(txb, 0, sizeof(struct rtllib_txb));
> txb->nr_frags = nr_frags;
> txb->frag_size = cpu_to_le16(txb_size);
>
> --
> 2.25.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20201023100317.4473-1-eafanasova%40gmail.com.
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging/rtl8192e: replace kmalloc with kzalloc
2020-10-23 10:03 [PATCH] staging/rtl8192e: replace kmalloc with kzalloc Elena Afanasova
2020-10-23 10:30 ` [Outreachy kernel] " Julia Lawall
@ 2020-10-23 11:58 ` Matthew Wilcox
1 sibling, 0 replies; 3+ messages in thread
From: Matthew Wilcox @ 2020-10-23 11:58 UTC (permalink / raw)
To: Elena Afanasova; +Cc: devel, gregkh, outreachy-kernel
On Fri, Oct 23, 2020 at 03:03:17AM -0700, Elena Afanasova wrote:
> - txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags),
> - gfp_mask);
> + txb = kzalloc(sizeof(*txb) + (sizeof(u8 *) * nr_frags), gfp_mask);
This would be a good opportunity to use struct_size().
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-23 11:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23 10:03 [PATCH] staging/rtl8192e: replace kmalloc with kzalloc Elena Afanasova
2020-10-23 10:30 ` [Outreachy kernel] " Julia Lawall
2020-10-23 11:58 ` Matthew Wilcox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).