All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] Re: [Patch] kzalloc() conversion in drivers/usb
@ 2006-02-27 19:33 Greg KH
  2006-02-27 20:29 ` Eric Sesterhenn
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Greg KH @ 2006-02-27 19:33 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

On Mon, Feb 27, 2006 at 05:22:24PM +0100, Eric Sesterhenn wrote:
> hi,
> 
> this patch converts drivers/usb to kzalloc usage.
> Compile tested with allyes config.

A lot of these changes are already in the latest -mm tree.  Can you
rediff this against that tree instead?

> This also fixes a bug in drivers/usb/serial/cp2101.c
> where memset() was used before checking if kmalloc() returns NULL.
> 
> I think there also was a bug in drivers/usb/gadget/inode.c because
> it used sizeof(*data) for the kmalloc() and sizeof(data) for
> the memset(), since sizeof(data) just returns the size for a pointer.
> 
> I assume there is also a bug in drivers/usb/gadget/omap_udc.c
> in omap_alloc_request(), req gets allocated via kmalloc() and
> the function returns &req->req, no matter if req is NULL, which
> looks like a NULL dereference to me, maybe someone who is more familar
> with this code might have a look at it.

Care to send the gadget patches to the usb gadget maintainer separately?

thanks,

greg k-h

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in drivers/usb
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
@ 2006-02-27 20:29 ` Eric Sesterhenn
  2006-02-27 21:36 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/usb/gadget David Brownell
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Eric Sesterhenn @ 2006-02-27 20:29 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 29120 bytes --]

hi,
> A lot of these changes are already in the latest -mm tree.  Can you
> rediff this against that tree instead?

here we go.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/host/ehci-mem.c linux-2.6.16-rc4-mm2/drivers/usb/host/ehci-mem.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/host/ehci-mem.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/host/ehci-mem.c	2006-02-27 20:57:01.000000000 +0100
@@ -220,13 +220,9 @@ static int ehci_mem_init (struct ehci_hc
 		ehci->periodic [i] = EHCI_LIST_END;
 
 	/* software shadow of hardware table */
-	ehci->pshadow = kmalloc (ehci->periodic_size * sizeof (void *), flags);
-	if (ehci->pshadow == NULL) {
-		goto fail;
-	}
-	memset (ehci->pshadow, 0, ehci->periodic_size * sizeof (void *));
-
-	return 0;
+	ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags);
+	if (ehci->pshadow != NULL)
+		return 0;
 
 fail:
 	ehci_dbg (ehci, "couldn't init memory\n");
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/host/ehci-sched.c linux-2.6.16-rc4-mm2/drivers/usb/host/ehci-sched.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/host/ehci-sched.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/host/ehci-sched.c	2006-02-27 20:57:01.000000000 +0100
@@ -864,9 +864,8 @@ iso_sched_alloc (unsigned packets, gfp_t
 	int			size = sizeof *iso_sched;
 
 	size += packets * sizeof (struct ehci_iso_packet);
-	iso_sched = kmalloc (size, mem_flags);
+	iso_sched = kzalloc(size, mem_flags);
 	if (likely (iso_sched != NULL)) {
-		memset(iso_sched, 0, size);
 		INIT_LIST_HEAD (&iso_sched->td_list);
 	}
 	return iso_sched;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/host/hc_crisv10.c linux-2.6.16-rc4-mm2/drivers/usb/host/hc_crisv10.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/host/hc_crisv10.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/host/hc_crisv10.c	2006-02-27 20:57:01.000000000 +0100
@@ -2137,10 +2137,9 @@ static int etrax_usb_submit_bulk_urb(str
 	urb->status = -EINPROGRESS;
 
 	/* Setup the hcpriv data. */
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
 	assert(urb_priv != NULL);
 	/* This sets rx_offset to 0. */
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 	urb_priv->urb_state = NOT_STARTED;
 	urb->hcpriv = urb_priv;
 
@@ -2475,10 +2474,9 @@ static int etrax_usb_submit_ctrl_urb(str
 	urb->status = -EINPROGRESS;
 
 	/* Setup the hcpriv data. */
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
 	assert(urb_priv != NULL);
 	/* This sets rx_offset to 0. */
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 	urb_priv->urb_state = NOT_STARTED;
 	urb->hcpriv = urb_priv;
 
@@ -2767,9 +2765,8 @@ static void etrax_usb_add_to_intr_sb_lis
 	maxlen = usb_maxpacket(urb->dev, urb->pipe, usb_pipeout(urb->pipe));
 	interval = urb->interval;
 
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), KMALLOC_FLAG);
 	assert(urb_priv != NULL);
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 	urb->hcpriv = urb_priv;
 
 	first_ep = &TxIntrEPList[0];
@@ -2997,9 +2994,8 @@ static void etrax_usb_add_to_isoc_sb_lis
 
 	prev_sb_desc = next_sb_desc = temp_sb_desc = NULL;
 
-	urb_priv = kmalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
+	urb_priv = kzalloc(sizeof(etrax_urb_priv_t), GFP_ATOMIC);
 	assert(urb_priv != NULL);
-	memset(urb_priv, 0, sizeof(etrax_urb_priv_t));
 
 	urb->hcpriv = urb_priv;
 	urb_priv->epid = epid;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/media/ov511.c linux-2.6.16-rc4-mm2/drivers/usb/media/ov511.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/media/ov511.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/media/ov511.c	2006-02-27 20:57:01.000000000 +0100
@@ -5686,13 +5686,11 @@ ov51x_probe(struct usb_interface *intf, 
 	if (idesc->bInterfaceSubClass != 0x00)
 		return -ENODEV;
 
-	if ((ov = kmalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
+	if ((ov = kzalloc(sizeof(*ov), GFP_KERNEL)) == NULL) {
 		err("couldn't kmalloc ov struct");
 		goto error_out;
 	}
 
-	memset(ov, 0, sizeof(*ov));
-
 	ov->dev = dev;
 	ov->iface = idesc->bInterfaceNumber;
 	ov->led_policy = led;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/media/pwc/pwc-if.c linux-2.6.16-rc4-mm2/drivers/usb/media/pwc/pwc-if.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/media/pwc/pwc-if.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/media/pwc/pwc-if.c	2006-02-27 20:56:57.000000000 +0100
@@ -1867,12 +1867,11 @@ static int usb_pwc_probe(struct usb_inte
 		Info("Warning: more than 1 configuration available.\n");
 
 	/* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */
-	pdev = kmalloc(sizeof(struct pwc_device), GFP_KERNEL);
+	pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL);
 	if (pdev == NULL) {
 		Err("Oops, could not allocate memory for pwc_device.\n");
 		return -ENOMEM;
 	}
-	memset(pdev, 0, sizeof(struct pwc_device));
 	pdev->type = type_id;
 	pdev->vsize = default_size;
 	pdev->vframes = default_fps;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/media/se401.c linux-2.6.16-rc4-mm2/drivers/usb/media/se401.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/media/se401.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/media/se401.c	2006-02-27 20:57:01.000000000 +0100
@@ -1345,13 +1345,11 @@ static int se401_probe(struct usb_interf
         /* We found one */
         info("SE401 camera found: %s", camera_name);
 
-        if ((se401 = kmalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
+        if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
                 err("couldn't kmalloc se401 struct");
 		return -ENOMEM;
         }
 
-        memset(se401, 0, sizeof(*se401));
-
         se401->dev = dev;
         se401->iface = interface->bInterfaceNumber;
         se401->camera_name = camera_name;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/media/stv680.c linux-2.6.16-rc4-mm2/drivers/usb/media/stv680.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/media/stv680.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/media/stv680.c	2006-02-27 20:57:01.000000000 +0100
@@ -318,12 +318,11 @@ static int stv_init (struct usb_stv *stv
 	unsigned char *buffer;
 	unsigned long int bufsize;
 
-	buffer = kmalloc (40, GFP_KERNEL);
+	buffer = kzalloc (40, GFP_KERNEL);
 	if (buffer == NULL) {
 		PDEBUG (0, "STV(e): Out of (small buf) memory");
 		return -1;
 	}
-	memset (buffer, 0, 40);
 	udelay (100);
 
 	/* set config 1, interface 0, alternate 0 */
@@ -1388,14 +1387,12 @@ static int stv680_probe (struct usb_inte
 		goto error;
 	}
 	/* We found one */
-	if ((stv680 = kmalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
+	if ((stv680 = kzalloc (sizeof (*stv680), GFP_KERNEL)) == NULL) {
 		PDEBUG (0, "STV(e): couldn't kmalloc stv680 struct.");
 		retval = -ENOMEM;
 		goto error;
 	}
 
-	memset (stv680, 0, sizeof (*stv680));
-
 	stv680->udev = dev;
 	stv680->camera_name = camera_name;
 
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/misc/auerswald.c linux-2.6.16-rc4-mm2/drivers/usb/misc/auerswald.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/misc/auerswald.c	2006-02-27 20:55:38.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/misc/auerswald.c	2006-02-27 20:57:13.000000000 +0100
@@ -570,10 +570,9 @@ static int auerchain_setup (pauerchain_t
 
         /* fill the list of free elements */
         for (;numElements; numElements--) {
-                acep = (pauerchainelement_t) kmalloc (sizeof (auerchainelement_t), GFP_KERNEL);
+                acep = kzalloc(sizeof(auerchainelement_t), GFP_KERNEL);
                 if (!acep)
 			goto ac_fail;
-		memset (acep, 0, sizeof (auerchainelement_t));
                 INIT_LIST_HEAD (&acep->list);
                 list_add_tail (&acep->list, &acp->free_list);
         }
@@ -761,10 +760,9 @@ static int auerbuf_setup (pauerbufctl_t 
 
         /* fill the list of free elements */
         for (;numElements; numElements--) {
-                bep = (pauerbuf_t) kmalloc (sizeof (auerbuf_t), GFP_KERNEL);
+                bep = kzalloc(sizeof(auerbuf_t), GFP_KERNEL);
                 if (!bep)
 			goto bl_fail;
-	        memset (bep, 0, sizeof (auerbuf_t));
                 bep->list = bcp;
                 INIT_LIST_HEAD (&bep->buff_list);
                 bep->bufp = kmalloc (bufsize, GFP_KERNEL);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/misc/usblcd.c linux-2.6.16-rc4-mm2/drivers/usb/misc/usblcd.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/misc/usblcd.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/misc/usblcd.c	2006-02-27 20:57:11.000000000 +0100
@@ -270,12 +270,11 @@ static int lcd_probe(struct usb_interfac
 	int retval = -ENOMEM;
 
 	/* allocate memory for our device state and initialize it */
-	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
 		err("Out of memory");
 		goto error;
 	}
-	memset(dev, 0x00, sizeof(*dev));
 	kref_init(&dev->kref);
 
 	dev->udev = usb_get_dev(interface_to_usbdev(interface));
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/misc/usbtest.c linux-2.6.16-rc4-mm2/drivers/usb/misc/usbtest.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/misc/usbtest.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/misc/usbtest.c	2006-02-27 20:57:11.000000000 +0100
@@ -382,12 +382,11 @@ alloc_sglist (int nents, int max, int va
 	for (i = 0; i < nents; i++) {
 		char		*buf;
 
-		buf = kmalloc (size, SLAB_KERNEL);
+		buf = kzalloc (size, SLAB_KERNEL);
 		if (!buf) {
 			free_sglist (sg, i);
 			return NULL;
 		}
-		memset (buf, 0, size);
 
 		/* kmalloc pages are always physically contiguous! */
 		sg_init_one(&sg[i], buf, size);
@@ -842,10 +841,9 @@ test_ctrl_queue (struct usbtest_dev *dev
 	 * as with bulk/intr sglists, sglen is the queue depth; it also
 	 * controls which subtests run (more tests than sglen) or rerun.
 	 */
-	urb = kmalloc (param->sglen * sizeof (struct urb *), SLAB_KERNEL);
+	urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL);
 	if (!urb)
 		return -ENOMEM;
-	memset (urb, 0, param->sglen * sizeof (struct urb *));
 	for (i = 0; i < param->sglen; i++) {
 		int			pipe = usb_rcvctrlpipe (udev, 0);
 		unsigned		len;
@@ -1865,10 +1863,9 @@ usbtest_probe (struct usb_interface *int
 	}
 #endif
 
-	dev = kmalloc (sizeof *dev, SLAB_KERNEL);
+	dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
 	if (!dev)
 		return -ENOMEM;
-	memset (dev, 0, sizeof *dev);
 	info = (struct usbtest_info *) id->driver_info;
 	dev->info = info;
 	init_MUTEX (&dev->sem);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/mon/mon_main.c linux-2.6.16-rc4-mm2/drivers/usb/mon/mon_main.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/mon/mon_main.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/mon/mon_main.c	2006-02-27 20:57:14.000000000 +0100
@@ -277,9 +277,8 @@ static void mon_bus_init(struct dentry *
 	char name[NAMESZ];
 	int rc;
 
-	if ((mbus = kmalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL)
+	if ((mbus = kzalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL)
 		goto err_alloc;
-	memset(mbus, 0, sizeof(struct mon_bus));
 	kref_init(&mbus->ref);
 	spin_lock_init(&mbus->lock);
 	INIT_LIST_HEAD(&mbus->r_list);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/mon/mon_text.c linux-2.6.16-rc4-mm2/drivers/usb/mon/mon_text.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/mon/mon_text.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/mon/mon_text.c	2006-02-27 20:57:14.000000000 +0100
@@ -213,12 +213,11 @@ static int mon_text_open(struct inode *i
 	mbus = inode->u.generic_ip;
 	ubus = mbus->u_bus;
 
-	rp = kmalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
+	rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
 	if (rp == NULL) {
 		rc = -ENOMEM;
 		goto err_alloc;
 	}
-	memset(rp, 0, sizeof(struct mon_reader_text));
 	INIT_LIST_HEAD(&rp->e_list);
 	init_waitqueue_head(&rp->wait);
 	mutex_init(&rp->printf_lock);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/net/zd1201.c linux-2.6.16-rc4-mm2/drivers/usb/net/zd1201.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/net/zd1201.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/net/zd1201.c	2006-02-27 20:56:14.000000000 +0100
@@ -621,10 +621,9 @@ static int zd1201_drvr_start(struct zd12
 	__le16 zdmax;
 	unsigned char *buffer;
 	
-	buffer = kmalloc(ZD1201_RXSIZE, GFP_KERNEL);
+	buffer = kzalloc(ZD1201_RXSIZE, GFP_KERNEL);
 	if (!buffer)
 		return -ENOMEM;
-	memset(buffer, 0, ZD1201_RXSIZE);
 
 	usb_fill_bulk_urb(zd->rx_urb, zd->usb, 
 	    usb_rcvbulkpipe(zd->usb, zd->endp_in), buffer, ZD1201_RXSIZE,
@@ -1750,11 +1749,9 @@ static int zd1201_probe(struct usb_inter
 
 	usb = interface_to_usbdev(interface);
 
-	zd = kmalloc(sizeof(struct zd1201), GFP_KERNEL);
-	if (!zd) {
+	zd = kzalloc(sizeof(struct zd1201), GFP_KERNEL);
+	if (!zd)
 		return -ENOMEM;
-	}
-	memset(zd, 0, sizeof(struct zd1201));
 	zd->ap = ap;
 	zd->usb = usb;
 	zd->removed = 0;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/cp2101.c linux-2.6.16-rc4-mm2/drivers/usb/serial/cp2101.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/cp2101.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/cp2101.c	2006-02-27 20:57:01.000000000 +0100
@@ -169,9 +169,7 @@ static int cp2101_get_config(struct usb_
 	/* Number of integers required to contain the array */
 	length = (((size - 1) | 3) + 1)/4;
 
-	buf = kmalloc (length * sizeof(u32), GFP_KERNEL);
-	memset(buf, 0, length * sizeof(u32));
-
+	buf = kcalloc(length, sizeof(u32), GFP_KERNEL);
 	if (!buf) {
 		dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
 		return -ENOMEM;
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/cypress_m8.c linux-2.6.16-rc4-mm2/drivers/usb/serial/cypress_m8.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/cypress_m8.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/cypress_m8.c	2006-02-27 20:57:01.000000000 +0100
@@ -435,11 +435,10 @@ static int generic_startup (struct usb_s
 
 	dbg("%s - port %d", __FUNCTION__, serial->port[0]->number);
 
-	priv = kmalloc(sizeof (struct cypress_private), GFP_KERNEL);
+	priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-	memset(priv, 0x00, sizeof (struct cypress_private));
 	spin_lock_init(&priv->lock);
 	priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE);
 	if (priv->buf == NULL) {
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/ftdi_sio.c linux-2.6.16-rc4-mm2/drivers/usb/serial/ftdi_sio.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/ftdi_sio.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/ftdi_sio.c	2006-02-27 20:57:01.000000000 +0100
@@ -1135,12 +1135,11 @@ static int ftdi_sio_attach (struct usb_s
 	
 	dbg("%s",__FUNCTION__);
 
-	priv = kmalloc(sizeof(struct ftdi_private), GFP_KERNEL);
+	priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
 	if (!priv){
 		err("%s- kmalloc(%Zd) failed.", __FUNCTION__, sizeof(struct ftdi_private));
 		return -ENOMEM;
 	}
-	memset(priv, 0, sizeof(*priv));
 
 	spin_lock_init(&priv->rx_lock);
         init_waitqueue_head(&priv->delta_msr_wait);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/garmin_gps.c linux-2.6.16-rc4-mm2/drivers/usb/serial/garmin_gps.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/garmin_gps.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/garmin_gps.c	2006-02-27 20:57:01.000000000 +0100
@@ -1422,12 +1422,11 @@ static int garmin_attach (struct usb_ser
 
 	dbg("%s", __FUNCTION__);
 
-	garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL);
+	garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
 	if (garmin_data_p == NULL) {
 		dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset (garmin_data_p, 0, sizeof(struct garmin_data));
 	init_timer(&garmin_data_p->timer);
 	spin_lock_init(&garmin_data_p->lock);
 	INIT_LIST_HEAD(&garmin_data_p->pktlist);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/io_edgeport.c linux-2.6.16-rc4-mm2/drivers/usb/serial/io_edgeport.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/io_edgeport.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/io_edgeport.c	2006-02-27 20:57:01.000000000 +0100
@@ -2725,12 +2725,11 @@ static int edge_startup (struct usb_seri
 	dev = serial->dev;
 
 	/* create our private serial structure */
-	edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
+	edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
 	if (edge_serial == NULL) {
 		dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset (edge_serial, 0, sizeof(struct edgeport_serial));
 	spin_lock_init(&edge_serial->es_lock);
 	edge_serial->serial = serial;
 	usb_set_serial_data(serial, edge_serial);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/io_ti.c linux-2.6.16-rc4-mm2/drivers/usb/serial/io_ti.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/io_ti.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/io_ti.c	2006-02-27 20:57:01.000000000 +0100
@@ -2727,12 +2727,11 @@ static int edge_startup (struct usb_seri
 	dev = serial->dev;
 
 	/* create our private serial structure */
-	edge_serial = kmalloc (sizeof(struct edgeport_serial), GFP_KERNEL);
+	edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
 	if (edge_serial == NULL) {
 		dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset (edge_serial, 0, sizeof(struct edgeport_serial));
 	sema_init(&edge_serial->es_sem, 1);
 	edge_serial->serial = serial;
 	usb_set_serial_data(serial, edge_serial);
@@ -2745,12 +2744,11 @@ static int edge_startup (struct usb_seri
 
 	/* set up our port private structures */
 	for (i = 0; i < serial->num_ports; ++i) {
-		edge_port = kmalloc (sizeof(struct edgeport_port), GFP_KERNEL);
+		edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
 		if (edge_port == NULL) {
 			dev_err(&serial->dev->dev, "%s - Out of memory\n", __FUNCTION__);
 			goto cleanup;
 		}
-		memset (edge_port, 0, sizeof(struct edgeport_port));
 		spin_lock_init(&edge_port->ep_lock);
 		edge_port->ep_out_buf = edge_buf_alloc(EDGE_OUT_BUF_SIZE);
 		if (edge_port->ep_out_buf == NULL) {
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/ir-usb.c linux-2.6.16-rc4-mm2/drivers/usb/serial/ir-usb.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/ir-usb.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/ir-usb.c	2006-02-27 20:57:01.000000000 +0100
@@ -184,10 +184,9 @@ static struct irda_class_desc *irda_usb_
 	struct irda_class_desc *desc;
 	int ret;
 		
-	desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
+	desc = kzalloc(sizeof (struct irda_class_desc), GFP_KERNEL);
 	if (desc == NULL) 
 		return NULL;
-	memset(desc, 0, sizeof(struct irda_class_desc));
 	
 	ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0),
 			IU_REQ_GET_CLASS_DESC,
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/keyspan.c linux-2.6.16-rc4-mm2/drivers/usb/serial/keyspan.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/keyspan.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/keyspan.c	2006-02-27 20:57:01.000000000 +0100
@@ -2250,12 +2250,11 @@ static int keyspan_startup (struct usb_s
 	}
 
 	/* Setup private data for serial driver */
-	s_priv = kmalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
+	s_priv = kzalloc(sizeof(struct keyspan_serial_private), GFP_KERNEL);
 	if (!s_priv) {
 		dbg("%s - kmalloc for keyspan_serial_private failed.", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(s_priv, 0, sizeof(struct keyspan_serial_private));
 
 	s_priv->device_details = d_details;
 	usb_set_serial_data(serial, s_priv);
@@ -2263,12 +2262,11 @@ static int keyspan_startup (struct usb_s
 	/* Now setup per port private data */
 	for (i = 0; i < serial->num_ports; i++) {
 		port = serial->port[i];
-		p_priv = kmalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
+		p_priv = kzalloc(sizeof(struct keyspan_port_private), GFP_KERNEL);
 		if (!p_priv) {
 			dbg("%s - kmalloc for keyspan_port_private (%d) failed!.", __FUNCTION__, i);
 			return (1);
 		}
-		memset(p_priv, 0, sizeof(struct keyspan_port_private));
 		p_priv->device_details = d_details;
 		usb_set_serial_port_data(port, p_priv);
 	}
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/kobil_sct.c linux-2.6.16-rc4-mm2/drivers/usb/serial/kobil_sct.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/kobil_sct.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/kobil_sct.c	2006-02-27 20:57:01.000000000 +0100
@@ -255,11 +255,9 @@ static int kobil_open (struct usb_serial
 	}
 	
 	// allocate memory for transfer buffer
-	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);  
+	transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);  
 	if (! transfer_buffer) {
 		return -ENOMEM;
-	} else {
-		memset(transfer_buffer, 0, transfer_buffer_length);
 	}
 	
 	// allocate write_urb
@@ -383,11 +381,10 @@ static void kobil_read_int_callback( str
 		
 		// BEGIN DEBUG
 		/*
-		  dbg_data = (unsigned char *) kmalloc((3 *  purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
+		  dbg_data = kzalloc((3 *  purb->actual_length + 10) * sizeof(char), GFP_KERNEL);
 		  if (! dbg_data) {
 		  return;
 		  }
-		  memset(dbg_data, 0, (3 *  purb->actual_length + 10));
 		  for (i = 0; i < purb->actual_length; i++) { 
 		  sprintf(dbg_data +3*i, "%02X ", data[i]); 
 		  }
@@ -518,11 +515,10 @@ static int kobil_tiocmget(struct usb_ser
 	}
 
 	// allocate memory for transfer buffer
-	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);  
+	transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);  
 	if (!transfer_buffer) {
 		return -ENOMEM;
 	}
-	memset(transfer_buffer, 0, transfer_buffer_length);
 
 	result = usb_control_msg( port->serial->dev, 
 				  usb_rcvctrlpipe(port->serial->dev, 0 ), 
@@ -564,11 +560,10 @@ static int  kobil_tiocmset(struct usb_se
 	}
 
 	// allocate memory for transfer buffer
-	transfer_buffer = (unsigned char *) kmalloc(transfer_buffer_length, GFP_KERNEL);
+	transfer_buffer = kzalloc(transfer_buffer_length, GFP_KERNEL);
 	if (! transfer_buffer) {
 		return -ENOMEM;
 	}
-	memset(transfer_buffer, 0, transfer_buffer_length);
 
 	if (set & TIOCM_RTS)
 		rts = 1;
@@ -655,11 +650,10 @@ static int  kobil_ioctl(struct usb_seria
 						   (struct termios __user *)arg))
 			return -EFAULT;
 		
-		settings = (unsigned char *) kmalloc(50, GFP_KERNEL);  
+		settings = kzalloc(50, GFP_KERNEL);  
 		if (! settings) {
 			return -ENOBUFS;
 		}
-		memset(settings, 0, 50);
 
 		switch (priv->internal_termios.c_cflag & CBAUD) {
 		case B1200:
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/mct_u232.c linux-2.6.16-rc4-mm2/drivers/usb/serial/mct_u232.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/mct_u232.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/mct_u232.c	2006-02-27 20:57:01.000000000 +0100
@@ -348,10 +348,9 @@ static int mct_u232_startup (struct usb_
 	struct mct_u232_private *priv;
 	struct usb_serial_port *port, *rport;
 
-	priv = kmalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
+	priv = kzalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
-	memset(priv, 0, sizeof(struct mct_u232_private));
 	spin_lock_init(&priv->lock);
 	usb_set_serial_port_data(serial->port[0], priv);
 
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/option.c linux-2.6.16-rc4-mm2/drivers/usb/serial/option.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/option.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/option.c	2006-02-27 20:57:01.000000000 +0100
@@ -631,13 +631,12 @@ static int option_startup(struct usb_ser
 	/* Now setup per port private data */
 	for (i = 0; i < serial->num_ports; i++) {
 		port = serial->port[i];
-		portdata = kmalloc(sizeof(*portdata), GFP_KERNEL);
+		portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
 		if (!portdata) {
 			dbg("%s: kmalloc for option_port_private (%d) failed!.",
 					__FUNCTION__, i);
 			return (1);
 		}
-		memset(portdata, 0, sizeof(struct option_port_private));
 
 		usb_set_serial_port_data(port, portdata);
 
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/pl2303.c linux-2.6.16-rc4-mm2/drivers/usb/serial/pl2303.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/pl2303.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/pl2303.c	2006-02-27 20:57:01.000000000 +0100
@@ -218,10 +218,9 @@ static int pl2303_startup (struct usb_se
 	dbg("device type: %d", type);
 
 	for (i = 0; i < serial->num_ports; ++i) {
-		priv = kmalloc (sizeof (struct pl2303_private), GFP_KERNEL);
+		priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL);
 		if (!priv)
 			goto cleanup;
-		memset (priv, 0x00, sizeof (struct pl2303_private));
 		spin_lock_init(&priv->lock);
 		priv->buf = pl2303_buf_alloc(PL2303_BUF_SIZE);
 		if (priv->buf == NULL) {
@@ -383,12 +382,11 @@ static void pl2303_set_termios (struct u
 		}
 	}
 
-	buf = kmalloc (7, GFP_KERNEL);
+	buf = kzalloc (7, GFP_KERNEL);
 	if (!buf) {
 		dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
 		return;
 	}
-	memset (buf, 0x00, 0x07);
 	
 	i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0),
 			     GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/ti_usb_3410_5052.c linux-2.6.16-rc4-mm2/drivers/usb/serial/ti_usb_3410_5052.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/ti_usb_3410_5052.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/ti_usb_3410_5052.c	2006-02-27 20:57:01.000000000 +0100
@@ -416,12 +416,11 @@ static int ti_startup(struct usb_serial 
 	    dev->actconfig->desc.bConfigurationValue);
 
 	/* create device structure */
-	tdev = kmalloc(sizeof(struct ti_device), GFP_KERNEL);
+	tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL);
 	if (tdev == NULL) {
 		dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
 		return -ENOMEM;
 	}
-	memset(tdev, 0, sizeof(struct ti_device));
 	sema_init(&tdev->td_open_close_sem, 1);
 	tdev->td_serial = serial;
 	usb_set_serial_data(serial, tdev);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/usb-serial.c linux-2.6.16-rc4-mm2/drivers/usb/serial/usb-serial.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/usb-serial.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/usb-serial.c	2006-02-27 20:57:01.000000000 +0100
@@ -564,12 +564,11 @@ static struct usb_serial * create_serial
 {
 	struct usb_serial *serial;
 
-	serial = kmalloc (sizeof (*serial), GFP_KERNEL);
+	serial = kzalloc(sizeof(*serial), GFP_KERNEL);
 	if (!serial) {
 		dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
 		return NULL;
 	}
-	memset (serial, 0, sizeof(*serial));
 	serial->dev = usb_get_dev(dev);
 	serial->type = driver;
 	serial->interface = interface;
@@ -809,10 +808,9 @@ int usb_serial_probe(struct usb_interfac
 	serial->num_port_pointers = max_endpoints;
 	dbg("%s - setting up %d port structures for this device", __FUNCTION__, max_endpoints);
 	for (i = 0; i < max_endpoints; ++i) {
-		port = kmalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
+		port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL);
 		if (!port)
 			goto probe_error;
-		memset(port, 0x00, sizeof(struct usb_serial_port));
 		port->number = i + serial->minor;
 		port->serial = serial;
 		spin_lock_init(&port->lock);
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/visor.c linux-2.6.16-rc4-mm2/drivers/usb/serial/visor.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/serial/visor.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/serial/visor.c	2006-02-27 20:57:01.000000000 +0100
@@ -763,10 +763,9 @@ static int generic_startup(struct usb_se
 	int i;
 
 	for (i = 0; i < serial->num_ports; ++i) {
-		priv = kmalloc (sizeof(*priv), GFP_KERNEL);
+		priv = kzalloc (sizeof(*priv), GFP_KERNEL);
 		if (!priv)
 			return -ENOMEM;
-		memset (priv, 0x00, sizeof(*priv));
 		spin_lock_init(&priv->lock);
 		usb_set_serial_port_data(serial->port[i], priv);
 	}
diff -upr linux-2.6.16-rc4-mm2.orig/drivers/usb/storage/isd200.c linux-2.6.16-rc4-mm2/drivers/usb/storage/isd200.c
--- linux-2.6.16-rc4-mm2.orig/drivers/usb/storage/isd200.c	2006-02-27 20:55:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/storage/isd200.c	2006-02-27 20:57:08.000000000 +0100
@@ -1382,7 +1382,7 @@ static int isd200_init_info(struct us_da
 	} else
 		US_DEBUGP("ERROR - kmalloc failure\n");
 
-	return(retStatus);
+	return retStatus;
 }
 
 /**************************************************************************



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in drivers/usb/gadget
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
  2006-02-27 20:29 ` Eric Sesterhenn
@ 2006-02-27 21:36 ` David Brownell
  2006-02-28  9:20 ` Eric Sesterhenn
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David Brownell @ 2006-02-27 21:36 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 963 bytes --]

On Monday 27 February 2006 12:36 pm, Eric Sesterhenn wrote:

> I think there was a bug in drivers/usb/gadget/inode.c because
> it used sizeof(*data) for the kmalloc() and sizeof(data) for
> the memset(), since sizeof(data) just returns the size for a pointer.

Actually in that case it's safe, since all the fields get explicitly
initialized ... most of them right after the memset(), but a couple
of them later on before they're used.  But the same paranoia that
argued for explicit zeroing argues for your fix.  :)


> I assume there is also a bug in drivers/usb/gadget/omap_udc.c
> in omap_alloc_request(), req gets allocated via kmalloc() and
> the function returns &req->req, no matter if req is NULL, which
> looks like a NULL dereference to me, maybe someone who is more familar
> with this code might have a look at it.

That should get fixed too.  Please roll a patch for that.

I'll sign off the conversion patch and forward it to Greg.
Thanks!

- Dave

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in drivers/usb/gadget
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
  2006-02-27 20:29 ` Eric Sesterhenn
  2006-02-27 21:36 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/usb/gadget David Brownell
@ 2006-02-28  9:20 ` Eric Sesterhenn
  2006-03-01  0:18 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Håkon Løvdal
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Eric Sesterhenn @ 2006-02-28  9:20 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1120 bytes --]

hi,
> > I assume there is also a bug in drivers/usb/gadget/omap_udc.c
> > in omap_alloc_request(), req gets allocated via kmalloc() and
> > the function returns &req->req, no matter if req is NULL, which
> > looks like a NULL dereference to me, maybe someone who is more familar
> > with this code might have a look at it.
> 
> That should get fixed too.  Please roll a patch for that.
> 
> I'll sign off the conversion patch and forward it to Greg.
> Thanks!

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

--- linux-2.6.16-rc4-mm2/drivers/usb/gadget/omap_udc.c.orig	2006-02-28 10:17:39.000000000 +0100
+++ linux-2.6.16-rc4-mm2/drivers/usb/gadget/omap_udc.c	2006-02-28 10:18:53.000000000 +0100
@@ -273,12 +273,13 @@ omap_alloc_request(struct usb_ep *ep, gf
 {
 	struct omap_req	*req;
 
-	req = kmalloc(sizeof *req, gfp_flags);
-	if (req) {
-		memset (req, 0, sizeof *req);
-		req->req.dma = DMA_ADDR_INVALID;
-		INIT_LIST_HEAD (&req->queue);
-	}
+	req = kzalloc(sizeof *req, gfp_flags);
+	if (!req)
+		return NULL;
+	
+	req->req.dma = DMA_ADDR_INVALID;
+	INIT_LIST_HEAD (&req->queue);
+	
 	return &req->req;
 }
 



[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] Re: [Patch] kzalloc() conversion in drivers/usb
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (2 preceding siblings ...)
  2006-02-28  9:20 ` Eric Sesterhenn
@ 2006-03-01  0:18 ` Håkon Løvdal
  2006-03-06 10:42 ` [KJ] Re: [Patch] kzalloc() conversion in crypto/ Herbert Xu
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Håkon Løvdal @ 2006-03-01  0:18 UTC (permalink / raw)
  To: kernel-janitors

On 2/27/06, Eric Sesterhenn <snakebyte@gmx.de> wrote:
> --- linux-2.6.16-rc4-mm2.orig/drivers/usb/host/ehci-mem.c       2006-02-27 20:55:38.000000000 +0100
> +++ linux-2.6.16-rc4-mm2/drivers/usb/host/ehci-mem.c    2006-02-27 20:57:01.000000000 +0100
> @@ -220,13 +220,9 @@ static int ehci_mem_init (struct ehci_hc
>                 ehci->periodic [i] = EHCI_LIST_END;
>
>         /* software shadow of hardware table */
> -       ehci->pshadow = kmalloc (ehci->periodic_size * sizeof (void *), flags);
> -       if (ehci->pshadow = NULL) {
> -               goto fail;
> -       }
> -       memset (ehci->pshadow, 0, ehci->periodic_size * sizeof (void *));
> -
> -       return 0;
> +       ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags);
> +       if (ehci->pshadow != NULL)
> +               return 0;
>
>  fail:
>         ehci_dbg (ehci, "couldn't init memory\n");

The following is just my personal opinion, but I would rather have the
code written as

+       ehci->pshadow = kcalloc(ehci->periodic_size, sizeof(void *), flags);
+       if (ehci->pshadow = NULL)
+               goto fail;
+       return 0;

so that the code conceptually reads
        normal_code...;
        if (error_condition)
                handle_error...;
        normal_code...;
instead of
        normal_code...;
        if (!error_condition)
                normal_code...;

BR Håkon Løvdal

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in crypto/
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (3 preceding siblings ...)
  2006-03-01  0:18 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Håkon Løvdal
@ 2006-03-06 10:42 ` Herbert Xu
  2006-03-06 20:57 ` [KJ] Re: [Patch] kzalloc() conversion in arch/sparc64 David S. Miller
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Herbert Xu @ 2006-03-06 10:42 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 392 bytes --]

On Sun, Mar 05, 2006 at 04:02:20PM +0100, Eric Sesterhenn wrote:
> 
> this patch converts crypto/ to kzalloc usage.
> Compile tested with allyesconfig.

Patch applied.  Thanks Eric.
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in arch/sparc64
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (4 preceding siblings ...)
  2006-03-06 10:42 ` [KJ] Re: [Patch] kzalloc() conversion in crypto/ Herbert Xu
@ 2006-03-06 20:57 ` David S. Miller
  2006-03-08 10:20 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/block Jens Axboe
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: David S. Miller @ 2006-03-06 20:57 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: Text/Plain, Size: 268 bytes --]

From: Eric Sesterhenn <snakebyte@gmx.de>
Date: Mon, 06 Mar 2006 21:13:30 +0100

> this patch converts arch/sparc64 to kzalloc usage.
> Crosscompile tested with allyesconfig.
> 
> Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>

Thanks, I'll queue this up for 2.6.17

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in drivers/block
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (5 preceding siblings ...)
  2006-03-06 20:57 ` [KJ] Re: [Patch] kzalloc() conversion in arch/sparc64 David S. Miller
@ 2006-03-08 10:20 ` Jens Axboe
  2006-03-08 10:22 ` Jens Axboe
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2006-03-08 10:20 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 185 bytes --]

On Sun, Mar 05 2006, Eric Sesterhenn wrote:
> hi, 
> 
> this patch converts drivers/block to kzalloc usage.
> Compile tested with allyesconfig.

Thanks Eric, applied.


-- 
Jens Axboe


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* [KJ] Re: [Patch] kzalloc() conversion in drivers/block
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (6 preceding siblings ...)
  2006-03-08 10:20 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/block Jens Axboe
@ 2006-03-08 10:22 ` Jens Axboe
  2006-03-08 12:21 ` Christoph Hellwig
  2006-03-08 12:30 ` Jens Axboe
  9 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2006-03-08 10:22 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

On Sat, Mar 04 2006, Eric Sesterhenn wrote:
> hi,
> 
> this patch converts drivers/block to kzalloc usage.
> Compile tested with allyesconfig.

Yet you use kcalloc in some places? Please just use kzalloc.

-- 
Jens Axboe


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] Re: [Patch] kzalloc() conversion in drivers/block
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (7 preceding siblings ...)
  2006-03-08 10:22 ` Jens Axboe
@ 2006-03-08 12:21 ` Christoph Hellwig
  2006-03-08 12:30 ` Jens Axboe
  9 siblings, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2006-03-08 12:21 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

On Wed, Mar 08, 2006 at 11:22:44AM +0100, Jens Axboe wrote:
> On Sat, Mar 04 2006, Eric Sesterhenn wrote:
> > hi,
> > 
> > this patch converts drivers/block to kzalloc usage.
> > Compile tested with allyesconfig.
> 
> Yet you use kcalloc in some places? Please just use kzalloc.

kcalloc is the canonical form of zeroed array allocations, so there's not
reason to not use it here.  it should have been mentioned in the description,
though.


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] Re: [Patch] kzalloc() conversion in drivers/block
  2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
                   ` (8 preceding siblings ...)
  2006-03-08 12:21 ` Christoph Hellwig
@ 2006-03-08 12:30 ` Jens Axboe
  9 siblings, 0 replies; 11+ messages in thread
From: Jens Axboe @ 2006-03-08 12:30 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 584 bytes --]

On Wed, Mar 08 2006, Christoph Hellwig wrote:
> On Wed, Mar 08, 2006 at 11:22:44AM +0100, Jens Axboe wrote:
> > On Sat, Mar 04 2006, Eric Sesterhenn wrote:
> > > hi,
> > > 
> > > this patch converts drivers/block to kzalloc usage.
> > > Compile tested with allyesconfig.
> > 
> > Yet you use kcalloc in some places? Please just use kzalloc.
> 
> kcalloc is the canonical form of zeroed array allocations, so there's not
> reason to not use it here.  it should have been mentioned in the description,
> though.

I already did the kzalloc myself, I prefer it that way.

-- 
Jens Axboe


[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2006-03-08 12:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-27 19:33 [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Greg KH
2006-02-27 20:29 ` Eric Sesterhenn
2006-02-27 21:36 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/usb/gadget David Brownell
2006-02-28  9:20 ` Eric Sesterhenn
2006-03-01  0:18 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/usb Håkon Løvdal
2006-03-06 10:42 ` [KJ] Re: [Patch] kzalloc() conversion in crypto/ Herbert Xu
2006-03-06 20:57 ` [KJ] Re: [Patch] kzalloc() conversion in arch/sparc64 David S. Miller
2006-03-08 10:20 ` [KJ] Re: [Patch] kzalloc() conversion in drivers/block Jens Axboe
2006-03-08 10:22 ` Jens Axboe
2006-03-08 12:21 ` Christoph Hellwig
2006-03-08 12:30 ` Jens Axboe

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.