All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] use kzalloc
@ 2022-03-12 10:26 ` Julia Lawall
  0 siblings, 0 replies; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:26 UTC (permalink / raw)
  To: linux-wireless
  Cc: kernel-janitors, alsa-devel, samba-technical, linux-cifs,
	linux-kernel, netdev, linux-rdma, linux-scsi, Andrey Konovalov,
	linux-usb

Use kzalloc instead of kmalloc + memset.

---

 drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
 drivers/net/wireless/zydas/zd1201.c        |    3 +--
 drivers/scsi/lpfc/lpfc_debugfs.c           |    9 ++-------
 drivers/usb/gadget/legacy/raw_gadget.c     |    3 +--
 fs/cifs/transport.c                        |    3 +--
 sound/core/seq/oss/seq_oss_init.c          |    3 +--
 6 files changed, 7 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 0/6] use kzalloc
@ 2022-03-12 10:26 ` Julia Lawall
  0 siblings, 0 replies; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:26 UTC (permalink / raw)
  To: linux-wireless
  Cc: linux-cifs, alsa-devel, linux-scsi, kernel-janitors, netdev,
	linux-usb, samba-technical, linux-kernel, linux-rdma,
	Andrey Konovalov

Use kzalloc instead of kmalloc + memset.

---

 drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
 drivers/net/wireless/zydas/zd1201.c        |    3 +--
 drivers/scsi/lpfc/lpfc_debugfs.c           |    9 ++-------
 drivers/usb/gadget/legacy/raw_gadget.c     |    3 +--
 fs/cifs/transport.c                        |    3 +--
 sound/core/seq/oss/seq_oss_init.c          |    3 +--
 6 files changed, 7 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/6] cifs: use kzalloc
  2022-03-12 10:26 ` Julia Lawall
  (?)
@ 2022-03-12 10:27 ` Julia Lawall
  2022-03-15  4:15   ` Steve French
  -1 siblings, 1 reply; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: Steve French; +Cc: kernel-janitors, linux-cifs, samba-technical, linux-kernel

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>

---
 fs/cifs/transport.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index eeb1a699bd6f..4ff8e165a180 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -464,13 +464,12 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 		return -EIO;
 	}
 
-	tr_hdr = kmalloc(sizeof(*tr_hdr), GFP_NOFS);
+	tr_hdr = kzalloc(sizeof(*tr_hdr), GFP_NOFS);
 	if (!tr_hdr)
 		return -ENOMEM;
 
 	memset(&cur_rqst[0], 0, sizeof(cur_rqst));
 	memset(&iov, 0, sizeof(iov));
-	memset(tr_hdr, 0, sizeof(*tr_hdr));
 
 	iov.iov_base = tr_hdr;
 	iov.iov_len = sizeof(*tr_hdr);


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/6] net/mlx4_en: use kzalloc
  2022-03-12 10:26 ` Julia Lawall
  (?)
  (?)
@ 2022-03-12 10:27 ` Julia Lawall
  2022-03-14 12:37   ` Tariq Toukan
  -1 siblings, 1 reply; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: Tariq Toukan
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, linux-kernel

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/ethernet/mellanox/mlx4/en_rx.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 8cfc649f226b..8f762fc170b3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -1067,7 +1067,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
 	struct mlx4_qp_context *context;
 	int err = 0;
 
-	context = kmalloc(sizeof(*context), GFP_KERNEL);
+	context = kzalloc(sizeof(*context), GFP_KERNEL);
 	if (!context)
 		return -ENOMEM;
 
@@ -1078,7 +1078,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
 	}
 	qp->event = mlx4_en_sqp_event;
 
-	memset(context, 0, sizeof(*context));
 	mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
 				qpn, ring->cqn, -1, context);
 	context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/6] ALSA: seq: oss: use kzalloc
  2022-03-12 10:26 ` Julia Lawall
@ 2022-03-12 10:27   ` Julia Lawall
  -1 siblings, 0 replies; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: kernel-janitors, Takashi Iwai, alsa-devel, linux-kernel

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>

---
 sound/core/seq/oss/seq_oss_init.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index 0ee4a5081fd6..04a3376a6e66 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -66,7 +66,7 @@ snd_seq_oss_create_client(void)
 	struct snd_seq_port_info *port;
 	struct snd_seq_port_callback port_callback;
 
-	port = kmalloc(sizeof(*port), GFP_KERNEL);
+	port = kzalloc(sizeof(*port), GFP_KERNEL);
 	if (!port) {
 		rc = -ENOMEM;
 		goto __error;
@@ -81,7 +81,6 @@ snd_seq_oss_create_client(void)
 	system_client = rc;
 
 	/* create annoucement receiver port */
-	memset(port, 0, sizeof(*port));
 	strcpy(port->name, "Receiver");
 	port->addr.client = system_client;
 	port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/6] ALSA: seq: oss: use kzalloc
@ 2022-03-12 10:27   ` Julia Lawall
  0 siblings, 0 replies; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: alsa-devel, kernel-janitors, Takashi Iwai, linux-kernel

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>

---
 sound/core/seq/oss/seq_oss_init.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index 0ee4a5081fd6..04a3376a6e66 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -66,7 +66,7 @@ snd_seq_oss_create_client(void)
 	struct snd_seq_port_info *port;
 	struct snd_seq_port_callback port_callback;
 
-	port = kmalloc(sizeof(*port), GFP_KERNEL);
+	port = kzalloc(sizeof(*port), GFP_KERNEL);
 	if (!port) {
 		rc = -ENOMEM;
 		goto __error;
@@ -81,7 +81,6 @@ snd_seq_oss_create_client(void)
 	system_client = rc;
 
 	/* create annoucement receiver port */
-	memset(port, 0, sizeof(*port));
 	strcpy(port->name, "Receiver");
 	port->addr.client = system_client;
 	port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-12 10:26 ` Julia Lawall
                   ` (3 preceding siblings ...)
  (?)
@ 2022-03-12 10:27 ` Julia Lawall
  2022-03-12 21:45   ` Joe Perches
  -1 siblings, 1 reply; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: James Smart
  Cc: kernel-janitors, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel

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/scsi/lpfc/lpfc_debugfs.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 30fac2f6fb06..7c4a71703065 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
 				 phba->hba_debugfs_root,
 				 phba, &lpfc_debugfs_op_slow_ring_trc);
 		if (!phba->slow_ring_trc) {
-			phba->slow_ring_trc = kmalloc(
-				(sizeof(struct lpfc_debugfs_trc) *
-				lpfc_debugfs_max_slow_ring_trc),
-				GFP_KERNEL);
+			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
+						      GFP_KERNEL);
 			if (!phba->slow_ring_trc) {
 				lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT,
 						 "0416 Cannot create debugfs "
@@ -6283,9 +6281,6 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
 				goto debug_failed;
 			}
 			atomic_set(&phba->slow_ring_trc_cnt, 0);
-			memset(phba->slow_ring_trc, 0,
-				(sizeof(struct lpfc_debugfs_trc) *
-				lpfc_debugfs_max_slow_ring_trc));
 		}
 
 		snprintf(name, sizeof(name), "nvmeio_trc");


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 5/6] zd1201: use kzalloc
  2022-03-12 10:26 ` Julia Lawall
                   ` (4 preceding siblings ...)
  (?)
@ 2022-03-12 10:27 ` Julia Lawall
  2022-03-16 15:29   ` Kalle Valo
  -1 siblings, 1 reply; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: Kalle Valo
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski, linux-wireless,
	netdev, linux-kernel

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(-)

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;


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 6/6] usb: raw-gadget: use kzalloc
  2022-03-12 10:26 ` Julia Lawall
                   ` (5 preceding siblings ...)
  (?)
@ 2022-03-12 10:27 ` Julia Lawall
  -1 siblings, 0 replies; 21+ messages in thread
From: Julia Lawall @ 2022-03-12 10:27 UTC (permalink / raw)
  To: Andrey Konovalov
  Cc: kernel-janitors, Felipe Balbi, Greg Kroah-Hartman, linux-usb,
	linux-kernel

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/usb/gadget/legacy/raw_gadget.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c
index d86c3a36441e..135e75b891f6 100644
--- a/drivers/usb/gadget/legacy/raw_gadget.c
+++ b/drivers/usb/gadget/legacy/raw_gadget.c
@@ -1157,7 +1157,7 @@ static int raw_ioctl_eps_info(struct raw_dev *dev, unsigned long value)
 	struct usb_raw_eps_info *info;
 	struct raw_ep *ep;
 
-	info = kmalloc(sizeof(*info), GFP_KERNEL);
+	info = kzalloc(sizeof(*info), GFP_KERNEL);
 	if (!info) {
 		ret = -ENOMEM;
 		goto out;
@@ -1177,7 +1177,6 @@ static int raw_ioctl_eps_info(struct raw_dev *dev, unsigned long value)
 		goto out_free;
 	}
 
-	memset(info, 0, sizeof(*info));
 	for (i = 0; i < dev->eps_num; i++) {
 		ep = &dev->eps[i];
 		strscpy(&info->eps[i].name[0], ep->ep->name,


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/6] ALSA: seq: oss: use kzalloc
  2022-03-12 10:27   ` Julia Lawall
@ 2022-03-12 21:43     ` Joe Perches
  -1 siblings, 0 replies; 21+ messages in thread
From: Joe Perches @ 2022-03-12 21:43 UTC (permalink / raw)
  To: Julia Lawall, Jaroslav Kysela
  Cc: kernel-janitors, Takashi Iwai, alsa-devel, linux-kernel

On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> Use kzalloc instead of kmalloc + memset.
[]
> diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
[]
> @@ -81,7 +81,6 @@ snd_seq_oss_create_client(void)
>  	system_client = rc;
>  
>  	/* create annoucement receiver port */

unrelated trivia: typo of announcement above

> -	memset(port, 0, sizeof(*port));
>  	strcpy(port->name, "Receiver");
>  	port->addr.client = system_client;
>  	port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */
> 



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/6] ALSA: seq: oss: use kzalloc
@ 2022-03-12 21:43     ` Joe Perches
  0 siblings, 0 replies; 21+ messages in thread
From: Joe Perches @ 2022-03-12 21:43 UTC (permalink / raw)
  To: Julia Lawall, Jaroslav Kysela
  Cc: alsa-devel, kernel-janitors, Takashi Iwai, linux-kernel

On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> Use kzalloc instead of kmalloc + memset.
[]
> diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
[]
> @@ -81,7 +81,6 @@ snd_seq_oss_create_client(void)
>  	system_client = rc;
>  
>  	/* create annoucement receiver port */

unrelated trivia: typo of announcement above

> -	memset(port, 0, sizeof(*port));
>  	strcpy(port->name, "Receiver");
>  	port->addr.client = system_client;
>  	port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* receive only */
> 



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-12 10:27 ` [PATCH 4/6] scsi: lpfc: " Julia Lawall
@ 2022-03-12 21:45   ` Joe Perches
  2022-03-14 11:34     ` Dan Carpenter
  0 siblings, 1 reply; 21+ messages in thread
From: Joe Perches @ 2022-03-12 21:45 UTC (permalink / raw)
  To: Julia Lawall, James Smart
  Cc: kernel-janitors, Dick Kennedy, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel

On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> Use kzalloc instead of kmalloc + memset.
[]
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
[]
> @@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
>  				 phba->hba_debugfs_root,
>  				 phba, &lpfc_debugfs_op_slow_ring_trc);
>  		if (!phba->slow_ring_trc) {
> -			phba->slow_ring_trc = kmalloc(
> -				(sizeof(struct lpfc_debugfs_trc) *
> -				lpfc_debugfs_max_slow_ring_trc),
> -				GFP_KERNEL);
> +			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
> +						      GFP_KERNEL);

kcalloc



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/6] ALSA: seq: oss: use kzalloc
  2022-03-12 10:27   ` Julia Lawall
@ 2022-03-13  8:09     ` Takashi Iwai
  -1 siblings, 0 replies; 21+ messages in thread
From: Takashi Iwai @ 2022-03-13  8:09 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Jaroslav Kysela, kernel-janitors, Takashi Iwai, alsa-devel, linux-kernel

On Sat, 12 Mar 2022 11:27:02 +0100,
Julia Lawall 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>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/6] ALSA: seq: oss: use kzalloc
@ 2022-03-13  8:09     ` Takashi Iwai
  0 siblings, 0 replies; 21+ messages in thread
From: Takashi Iwai @ 2022-03-13  8:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-kernel, alsa-devel, kernel-janitors, Takashi Iwai

On Sat, 12 Mar 2022 11:27:02 +0100,
Julia Lawall 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>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-12 21:45   ` Joe Perches
@ 2022-03-14 11:34     ` Dan Carpenter
  2022-03-14 11:50       ` Julia Lawall
  0 siblings, 1 reply; 21+ messages in thread
From: Dan Carpenter @ 2022-03-14 11:34 UTC (permalink / raw)
  To: Joe Perches
  Cc: Julia Lawall, James Smart, kernel-janitors, Dick Kennedy,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel, Harshit Mogalapalli

On Sat, Mar 12, 2022 at 01:45:01PM -0800, Joe Perches wrote:
> On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> > Use kzalloc instead of kmalloc + memset.
> []
> > diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
> []
> > @@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
> >  				 phba->hba_debugfs_root,
> >  				 phba, &lpfc_debugfs_op_slow_ring_trc);
> >  		if (!phba->slow_ring_trc) {
> > -			phba->slow_ring_trc = kmalloc(
> > -				(sizeof(struct lpfc_debugfs_trc) *
> > -				lpfc_debugfs_max_slow_ring_trc),
> > -				GFP_KERNEL);
> > +			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
> > +						      GFP_KERNEL);
> 
> kcalloc
> 

Did someone have a Coccinelle script that converted kzalloc() to
kcalloc()?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 4/6] scsi: lpfc: use kzalloc
  2022-03-14 11:34     ` Dan Carpenter
@ 2022-03-14 11:50       ` Julia Lawall
  0 siblings, 0 replies; 21+ messages in thread
From: Julia Lawall @ 2022-03-14 11:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Joe Perches, James Smart, kernel-janitors, Dick Kennedy,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi,
	linux-kernel, Harshit Mogalapalli, Kees Cook



On Mon, 14 Mar 2022, Dan Carpenter wrote:

> On Sat, Mar 12, 2022 at 01:45:01PM -0800, Joe Perches wrote:
> > On Sat, 2022-03-12 at 11:27 +0100, Julia Lawall wrote:
> > > Use kzalloc instead of kmalloc + memset.
> > []
> > > diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
> > []
> > > @@ -6272,10 +6272,8 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
> > >  				 phba->hba_debugfs_root,
> > >  				 phba, &lpfc_debugfs_op_slow_ring_trc);
> > >  		if (!phba->slow_ring_trc) {
> > > -			phba->slow_ring_trc = kmalloc(
> > > -				(sizeof(struct lpfc_debugfs_trc) *
> > > -				lpfc_debugfs_max_slow_ring_trc),
> > > -				GFP_KERNEL);
> > > +			phba->slow_ring_trc = kzalloc((sizeof(struct lpfc_debugfs_trc) * lpfc_debugfs_max_slow_ring_trc),
> > > +						      GFP_KERNEL);
> >
> > kcalloc
> >
>
> Did someone have a Coccinelle script that converted kzalloc() to
> kcalloc()?

Not sure if I have ever done that.  A long time ago, I made one that
starts with kmalloc and picks kzalloc or kcalloc.  Perhaps Kees did such a
thing?

I'll see if it would be useful.

julia

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/6] net/mlx4_en: use kzalloc
  2022-03-12 10:27 ` [PATCH 2/6] net/mlx4_en: " Julia Lawall
@ 2022-03-14 12:37   ` Tariq Toukan
  0 siblings, 0 replies; 21+ messages in thread
From: Tariq Toukan @ 2022-03-14 12:37 UTC (permalink / raw)
  To: Julia Lawall, Tariq Toukan
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski, netdev,
	linux-rdma, linux-kernel



On 3/12/2022 12:27 PM, Julia Lawall 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>
> 
> ---
>   drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> index 8cfc649f226b..8f762fc170b3 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
> @@ -1067,7 +1067,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
>   	struct mlx4_qp_context *context;
>   	int err = 0;
>   
> -	context = kmalloc(sizeof(*context), GFP_KERNEL);
> +	context = kzalloc(sizeof(*context), GFP_KERNEL);
>   	if (!context)
>   		return -ENOMEM;
>   
> @@ -1078,7 +1078,6 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn,
>   	}
>   	qp->event = mlx4_en_sqp_event;
>   
> -	memset(context, 0, sizeof(*context));
>   	mlx4_en_fill_qp_context(priv, ring->actual_size, ring->stride, 0, 0,
>   				qpn, ring->cqn, -1, context);
>   	context->db_rec_addr = cpu_to_be64(ring->wqres.db.dma);
> 

Thanks for your patch.

Reviewed-by: Tariq Toukan <tariqt@nvidia.com>


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/6] use kzalloc
  2022-03-12 10:26 ` Julia Lawall
@ 2022-03-14 20:30   ` patchwork-bot+netdevbpf
  -1 siblings, 0 replies; 21+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-14 20:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-wireless, kernel-janitors, alsa-devel, samba-technical,
	linux-cifs, linux-kernel, netdev, linux-rdma, linux-scsi,
	andreyknvl, linux-usb

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 12 Mar 2022 11:26:59 +0100 you wrote:
> Use kzalloc instead of kmalloc + memset.
> 
> ---
> 
>  drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
>  drivers/net/wireless/zydas/zd1201.c        |    3 +--
>  drivers/scsi/lpfc/lpfc_debugfs.c           |    9 ++-------
>  drivers/usb/gadget/legacy/raw_gadget.c     |    3 +--
>  fs/cifs/transport.c                        |    3 +--
>  sound/core/seq/oss/seq_oss_init.c          |    3 +--
>  6 files changed, 7 insertions(+), 17 deletions(-)

Here is the summary with links:
  - [2/6] net/mlx4_en: use kzalloc
    https://git.kernel.org/netdev/net-next/c/3c2dfb735b4a
  - [5/6] zd1201: use kzalloc
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/6] use kzalloc
@ 2022-03-14 20:30   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 21+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-14 20:30 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-cifs, alsa-devel, linux-scsi, linux-rdma, linux-wireless,
	linux-usb, kernel-janitors, linux-kernel, netdev,
	samba-technical, andreyknvl

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 12 Mar 2022 11:26:59 +0100 you wrote:
> Use kzalloc instead of kmalloc + memset.
> 
> ---
> 
>  drivers/net/ethernet/mellanox/mlx4/en_rx.c |    3 +--
>  drivers/net/wireless/zydas/zd1201.c        |    3 +--
>  drivers/scsi/lpfc/lpfc_debugfs.c           |    9 ++-------
>  drivers/usb/gadget/legacy/raw_gadget.c     |    3 +--
>  fs/cifs/transport.c                        |    3 +--
>  sound/core/seq/oss/seq_oss_init.c          |    3 +--
>  6 files changed, 7 insertions(+), 17 deletions(-)

Here is the summary with links:
  - [2/6] net/mlx4_en: use kzalloc
    https://git.kernel.org/netdev/net-next/c/3c2dfb735b4a
  - [5/6] zd1201: use kzalloc
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/6] cifs: use kzalloc
  2022-03-12 10:27 ` [PATCH 1/6] cifs: " Julia Lawall
@ 2022-03-15  4:15   ` Steve French
  0 siblings, 0 replies; 21+ messages in thread
From: Steve French @ 2022-03-15  4:15 UTC (permalink / raw)
  To: Julia Lawall; +Cc: kernel-janitors, CIFS, samba-technical, LKML

Which tree should this be merged from?  cifs-2.6.git for-next ... or
do you prefer that these all go together through a different tree

On Sun, Mar 13, 2022 at 11:36 AM 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>
>
> ---
>  fs/cifs/transport.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index eeb1a699bd6f..4ff8e165a180 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -464,13 +464,12 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
>                 return -EIO;
>         }
>
> -       tr_hdr = kmalloc(sizeof(*tr_hdr), GFP_NOFS);
> +       tr_hdr = kzalloc(sizeof(*tr_hdr), GFP_NOFS);
>         if (!tr_hdr)
>                 return -ENOMEM;
>
>         memset(&cur_rqst[0], 0, sizeof(cur_rqst));
>         memset(&iov, 0, sizeof(iov));
> -       memset(tr_hdr, 0, sizeof(*tr_hdr));
>
>         iov.iov_base = tr_hdr;
>         iov.iov_len = sizeof(*tr_hdr);
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 5/6] zd1201: use kzalloc
  2022-03-12 10:27 ` [PATCH 5/6] zd1201: " Julia Lawall
@ 2022-03-16 15:29   ` Kalle Valo
  0 siblings, 0 replies; 21+ messages in thread
From: Kalle Valo @ 2022-03-16 15:29 UTC (permalink / raw)
  To: Julia Lawall
  Cc: kernel-janitors, David S. Miller, Jakub Kicinski, linux-wireless,
	netdev, linux-kernel

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

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20220312102705.71413-6-Julia.Lawall@inria.fr/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-03-17  6:57 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-12 10:26 [PATCH 0/6] use kzalloc Julia Lawall
2022-03-12 10:26 ` Julia Lawall
2022-03-12 10:27 ` [PATCH 1/6] cifs: " Julia Lawall
2022-03-15  4:15   ` Steve French
2022-03-12 10:27 ` [PATCH 2/6] net/mlx4_en: " Julia Lawall
2022-03-14 12:37   ` Tariq Toukan
2022-03-12 10:27 ` [PATCH 3/6] ALSA: seq: oss: " Julia Lawall
2022-03-12 10:27   ` Julia Lawall
2022-03-12 21:43   ` Joe Perches
2022-03-12 21:43     ` Joe Perches
2022-03-13  8:09   ` Takashi Iwai
2022-03-13  8:09     ` Takashi Iwai
2022-03-12 10:27 ` [PATCH 4/6] scsi: lpfc: " Julia Lawall
2022-03-12 21:45   ` Joe Perches
2022-03-14 11:34     ` Dan Carpenter
2022-03-14 11:50       ` Julia Lawall
2022-03-12 10:27 ` [PATCH 5/6] zd1201: " Julia Lawall
2022-03-16 15:29   ` Kalle Valo
2022-03-12 10:27 ` [PATCH 6/6] usb: raw-gadget: " Julia Lawall
2022-03-14 20:30 ` [PATCH 0/6] " patchwork-bot+netdevbpf
2022-03-14 20:30   ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.