Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: io_edgeport: Use kzalloc

Use kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


authored by

Julia Lawall and committed by
Greg Kroah-Hartman
1ac93a30 b2c57379

+1 -2
+1 -2
drivers/usb/serial/io_edgeport.c
··· 3020 3020 3021 3021 /* set up our port private structures */ 3022 3022 for (i = 0; i < serial->num_ports; ++i) { 3023 - edge_port = kmalloc(sizeof(struct edgeport_port), GFP_KERNEL); 3023 + edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL); 3024 3024 if (edge_port == NULL) { 3025 3025 dev_err(&serial->dev->dev, "%s - Out of memory\n", 3026 3026 __func__); ··· 3033 3033 kfree(edge_serial); 3034 3034 return -ENOMEM; 3035 3035 } 3036 - memset(edge_port, 0, sizeof(struct edgeport_port)); 3037 3036 spin_lock_init(&edge_port->ep_lock); 3038 3037 edge_port->port = serial->port[i]; 3039 3038 usb_set_serial_port_data(serial->port[i], edge_port);