diff mbox series

[5/6] zd1201: use kzalloc

Message ID 20220312102705.71413-6-Julia.Lawall@inria.fr
State New
Headers show
Series use kzalloc | expand

Commit Message

Julia Lawall March 12, 2022, 10:27 a.m. UTC
Use kzalloc instead of kmalloc + memset.

The semantic patch that makes this change is:
(https://coccinelle.gitlabpages.inria.fr/website/)

//<smpl>
@@
expression res, size, flag;
@@
- res = kmalloc(size, flag);
+ res = kzalloc(size, flag);
  ...
- memset(res, 0, size);
//</smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 drivers/net/wireless/zydas/zd1201.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Kalle Valo March 16, 2022, 3:29 p.m. UTC | #1
Julia Lawall <Julia.Lawall@inria.fr> wrote:

> Use kzalloc instead of kmalloc + memset.
> 
> The semantic patch that makes this change is:
> (https://coccinelle.gitlabpages.inria.fr/website/)
> 
> //<smpl>
> @@
> expression res, size, flag;
> @@
> - res = kmalloc(size, flag);
> + res = kzalloc(size, flag);
>   ...
> - memset(res, 0, size);
> //</smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

Patch applied to wireless-next.git, thanks.

3c0e3ca6028b zd1201: use kzalloc
diff mbox series

Patch

diff --git a/drivers/net/wireless/zydas/zd1201.c b/drivers/net/wireless/zydas/zd1201.c
index e64e4e579518..82bc0d44212e 100644
--- a/drivers/net/wireless/zydas/zd1201.c
+++ b/drivers/net/wireless/zydas/zd1201.c
@@ -521,7 +521,7 @@  static int zd1201_setconfig(struct zd1201 *zd, int rid, const void *buf, int len
 	zd->rxdatas = 0;
 	zd->rxlen = 0;
 	for (seq=0; len > 0; seq++) {
-		request = kmalloc(16, gfp_mask);
+		request = kzalloc(16, gfp_mask);
 		if (!request)
 			return -ENOMEM;
 		urb = usb_alloc_urb(0, gfp_mask);
@@ -529,7 +529,6 @@  static int zd1201_setconfig(struct zd1201 *zd, int rid, const void *buf, int len
 			kfree(request);
 			return -ENOMEM;
 		}
-		memset(request, 0, 16);
 		reqlen = len>12 ? 12 : len;
 		request[0] = ZD1201_USB_RESREQ;
 		request[1] = seq;