1
0
Fork 0

some kmalloc/memset ->kzalloc (tree wide)

Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).

Here is a short excerpt of the semantic patch performing
this transformation:

@@
type T2;
expression x;
identifier f,fld;
expression E;
expression E1,E2;
expression e1,e2,e3,y;
statement S;
@@

 x =
- kmalloc
+ kzalloc
  (E1,E2)
  ...  when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
- memset((T2)x,0,E1);

@@
expression E1,E2,E3;
@@

- kzalloc(E1 * E2,E3)
+ kcalloc(E1,E2,E3)

[akpm@linux-foundation.org: get kcalloc args the right way around]
Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Acked-by: Russell King <rmk@arm.linux.org.uk>
Cc: Bryan Wu <bryan.wu@analog.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Acked-by: Roland Dreier <rolandd@cisco.com>
Cc: Jiri Kosina <jkosina@suse.cz>
Acked-by: Dmitry Torokhov <dtor@mail.ru>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Pierre Ossman <drzeus-list@drzeus.cx>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: "David S. Miller" <davem@davemloft.net>
Acked-by: Greg KH <greg@kroah.com>
Cc: James Bottomley <James.Bottomley@steeleye.com>
Cc: "Antonino A. Daplas" <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
hifive-unleashed-5.1
Yoann Padioleau 2007-07-19 01:49:03 -07:00 committed by Linus Torvalds
parent 3b5ad0797c
commit dd00cc486a
136 changed files with 157 additions and 330 deletions

View File

@ -124,9 +124,8 @@ static void cn_test_timer_func(unsigned long __data)
struct cn_msg *m; struct cn_msg *m;
char data[32]; char data[32];
m = kmalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC); m = kzalloc(sizeof(*m) + sizeof(data), GFP_ATOMIC);
if (m) { if (m) {
memset(m, 0, sizeof(*m) + sizeof(data));
memcpy(&m->id, &cn_test_id, sizeof(m->id)); memcpy(&m->id, &cn_test_id, sizeof(m->id));
m->seq = cn_test_timer_counter; m->seq = cn_test_timer_counter;

View File

@ -277,11 +277,10 @@ static struct config_item *simple_children_make_item(struct config_group *group,
{ {
struct simple_child *simple_child; struct simple_child *simple_child;
simple_child = kmalloc(sizeof(struct simple_child), GFP_KERNEL); simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL);
if (!simple_child) if (!simple_child)
return NULL; return NULL;
memset(simple_child, 0, sizeof(struct simple_child));
config_item_init_type_name(&simple_child->item, name, config_item_init_type_name(&simple_child->item, name,
&simple_child_type); &simple_child_type);
@ -364,12 +363,11 @@ static struct config_group *group_children_make_group(struct config_group *group
{ {
struct simple_children *simple_children; struct simple_children *simple_children;
simple_children = kmalloc(sizeof(struct simple_children), simple_children = kzalloc(sizeof(struct simple_children),
GFP_KERNEL); GFP_KERNEL);
if (!simple_children) if (!simple_children)
return NULL; return NULL;
memset(simple_children, 0, sizeof(struct simple_children));
config_group_init_type_name(&simple_children->group, name, config_group_init_type_name(&simple_children->group, name,
&simple_children_type); &simple_children_type);

View File

@ -119,8 +119,7 @@ module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
} }
nsyms = symtab->sh_size / sizeof(Elf64_Sym); nsyms = symtab->sh_size / sizeof(Elf64_Sym);
chains = kmalloc(nsyms * sizeof(struct got_entry), GFP_KERNEL); chains = kcalloc(nsyms, sizeof(struct got_entry), GFP_KERNEL);
memset(chains, 0, nsyms * sizeof(struct got_entry));
got->sh_size = 0; got->sh_size = 0;
got->sh_addralign = 8; got->sh_addralign = 8;

View File

@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
if (nr > 1) if (nr > 1)
return 0; return 0;
res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL); res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
if (!res) if (!res)
panic("PCI: unable to alloc resources"); panic("PCI: unable to alloc resources");
memset(res, 0, sizeof(struct resource) * 2);
/* 'nr' assumptions: /* 'nr' assumptions:
* ATUX is always 0 * ATUX is always 0

View File

@ -521,10 +521,9 @@ void *sram_alloc_with_lsl(size_t size, unsigned long flags)
struct sram_list_struct *lsl = NULL; struct sram_list_struct *lsl = NULL;
struct mm_struct *mm = current->mm; struct mm_struct *mm = current->mm;
lsl = kmalloc(sizeof(struct sram_list_struct), GFP_KERNEL); lsl = kzalloc(sizeof(struct sram_list_struct), GFP_KERNEL);
if (!lsl) if (!lsl)
return NULL; return NULL;
memset(lsl, 0, sizeof(*lsl));
if (flags & L1_INST_SRAM) if (flags & L1_INST_SRAM)
addr = l1_inst_sram_alloc(size); addr = l1_inst_sram_alloc(size);

View File

@ -91,14 +91,12 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
if (!mem_base) if (!mem_base)
goto out; goto out;
dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
if (!dev->dma_mem) if (!dev->dma_mem)
goto out; goto out;
memset(dev->dma_mem, 0, sizeof(struct dma_coherent_mem)); dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
dev->dma_mem->bitmap = kmalloc(bitmap_size, GFP_KERNEL);
if (!dev->dma_mem->bitmap) if (!dev->dma_mem->bitmap)
goto free1_out; goto free1_out;
memset(dev->dma_mem->bitmap, 0, bitmap_size);
dev->dma_mem->virt_base = mem_base; dev->dma_mem->virt_base = mem_base;
dev->dma_mem->device_base = device_addr; dev->dma_mem->device_base = device_addr;

View File

@ -248,7 +248,7 @@ static void parse_system_parameter_string(struct seq_file *m)
} else { } else {
int splpar_strlen; int splpar_strlen;
int idx, w_idx; int idx, w_idx;
char *workbuffer = kmalloc(SPLPAR_MAXLENGTH, GFP_KERNEL); char *workbuffer = kzalloc(SPLPAR_MAXLENGTH, GFP_KERNEL);
if (!workbuffer) { if (!workbuffer) {
printk(KERN_ERR "%s %s kmalloc failure at line %d \n", printk(KERN_ERR "%s %s kmalloc failure at line %d \n",
__FILE__, __FUNCTION__, __LINE__); __FILE__, __FUNCTION__, __LINE__);
@ -261,7 +261,6 @@ static void parse_system_parameter_string(struct seq_file *m)
splpar_strlen = local_buffer[0] * 256 + local_buffer[1]; splpar_strlen = local_buffer[0] * 256 + local_buffer[1];
local_buffer += 2; /* step over strlen value */ local_buffer += 2; /* step over strlen value */
memset(workbuffer, 0, SPLPAR_MAXLENGTH);
w_idx = 0; w_idx = 0;
idx = 0; idx = 0;
while ((*local_buffer) && (idx < splpar_strlen)) { while ((*local_buffer) && (idx < splpar_strlen)) {

View File

@ -222,10 +222,9 @@ struct of_device* of_platform_device_create(struct device_node *np,
{ {
struct of_device *dev; struct of_device *dev;
dev = kmalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
return NULL; return NULL;
memset(dev, 0, sizeof(*dev));
dev->node = of_node_get(np); dev->node = of_node_get(np);
dev->dma_mask = 0xffffffffUL; dev->dma_mask = 0xffffffffUL;

View File

@ -436,11 +436,10 @@ int sg_scsi_ioctl(struct file *file, struct request_queue *q,
bytes = max(in_len, out_len); bytes = max(in_len, out_len);
if (bytes) { if (bytes) {
buffer = kmalloc(bytes, q->bounce_gfp | GFP_USER| __GFP_NOWARN); buffer = kzalloc(bytes, q->bounce_gfp | GFP_USER| __GFP_NOWARN);
if (!buffer) if (!buffer)
return -ENOMEM; return -ENOMEM;
memset(buffer, 0, bytes);
} }
rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT); rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);

View File

@ -1608,7 +1608,7 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
} }
#endif #endif
host = kmalloc(sizeof(*host), GFP_KERNEL); host = kzalloc(sizeof(*host), GFP_KERNEL);
if (!host) { if (!host) {
printk(KERN_ERR DRV_NAME "(%s): memory alloc failure\n", printk(KERN_ERR DRV_NAME "(%s): memory alloc failure\n",
pci_name(pdev)); pci_name(pdev));
@ -1616,7 +1616,6 @@ static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_regions; goto err_out_regions;
} }
memset(host, 0, sizeof(*host));
host->pdev = pdev; host->pdev = pdev;
host->flags = pci_dac ? FL_DAC : 0; host->flags = pci_dac ? FL_DAC : 0;
spin_lock_init(&host->lock); spin_lock_init(&host->lock);

View File

@ -1721,12 +1721,11 @@ static int get_async_struct(int line, struct async_struct **ret_info)
*ret_info = sstate->info; *ret_info = sstate->info;
return 0; return 0;
} }
info = kmalloc(sizeof(struct async_struct), GFP_KERNEL); info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
if (!info) { if (!info) {
sstate->count--; sstate->count--;
return -ENOMEM; return -ENOMEM;
} }
memset(info, 0, sizeof(struct async_struct));
#ifdef DECLARE_WAITQUEUE #ifdef DECLARE_WAITQUEUE
init_waitqueue_head(&info->open_wait); init_waitqueue_head(&info->open_wait);
init_waitqueue_head(&info->close_wait); init_waitqueue_head(&info->close_wait);

View File

@ -273,10 +273,9 @@ via_alloc_desc_pages(drm_via_sg_info_t *vsg)
vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) / vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page - 1) /
vsg->descriptors_per_page; vsg->descriptors_per_page;
if (NULL == (vsg->desc_pages = kmalloc(sizeof(void *) * vsg->num_desc_pages, GFP_KERNEL))) if (NULL == (vsg->desc_pages = kcalloc(vsg->num_desc_pages, sizeof(void *), GFP_KERNEL)))
return DRM_ERR(ENOMEM); return DRM_ERR(ENOMEM);
memset(vsg->desc_pages, 0, sizeof(void *) * vsg->num_desc_pages);
vsg->state = dr_via_desc_pages_alloc; vsg->state = dr_via_desc_pages_alloc;
for (i=0; i<vsg->num_desc_pages; ++i) { for (i=0; i<vsg->num_desc_pages; ++i) {
if (NULL == (vsg->desc_pages[i] = if (NULL == (vsg->desc_pages[i] =

View File

@ -2459,7 +2459,7 @@ static int __init espserial_init(void)
return 1; return 1;
} }
info = kmalloc(sizeof(struct esp_struct), GFP_KERNEL); info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL);
if (!info) if (!info)
{ {
@ -2469,7 +2469,6 @@ static int __init espserial_init(void)
return 1; return 1;
} }
memset((void *)info, 0, sizeof(struct esp_struct));
spin_lock_init(&info->lock); spin_lock_init(&info->lock);
/* rx_trigger, tx_trigger are needed by autoconfig */ /* rx_trigger, tx_trigger are needed by autoconfig */
info->config.rx_trigger = rx_trigger; info->config.rx_trigger = rx_trigger;
@ -2527,7 +2526,7 @@ static int __init espserial_init(void)
if (!dma) if (!dma)
info->stat_flags |= ESP_STAT_NEVER_DMA; info->stat_flags |= ESP_STAT_NEVER_DMA;
info = kmalloc(sizeof(struct esp_struct), GFP_KERNEL); info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL);
if (!info) if (!info)
{ {
printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n");
@ -2536,7 +2535,6 @@ static int __init espserial_init(void)
return 0; return 0;
} }
memset((void *)info, 0, sizeof(struct esp_struct));
/* rx_trigger, tx_trigger are needed by autoconfig */ /* rx_trigger, tx_trigger are needed by autoconfig */
info->config.rx_trigger = rx_trigger; info->config.rx_trigger = rx_trigger;
info->config.tx_trigger = tx_trigger; info->config.tx_trigger = tx_trigger;

View File

@ -784,12 +784,10 @@ static int __devinit hvcs_probe(
return -EFAULT; return -EFAULT;
} }
hvcsd = kmalloc(sizeof(*hvcsd), GFP_KERNEL); hvcsd = kzalloc(sizeof(*hvcsd), GFP_KERNEL);
if (!hvcsd) if (!hvcsd)
return -ENODEV; return -ENODEV;
/* hvcsd->tty is zeroed out with the memset */
memset(hvcsd, 0x00, sizeof(*hvcsd));
spin_lock_init(&hvcsd->lock); spin_lock_init(&hvcsd->lock);
/* Automatically incs the refcount the first time */ /* Automatically incs the refcount the first time */

View File

@ -2639,10 +2639,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
return -ENODEV; return -ENODEV;
} }
intf = kmalloc(sizeof(*intf), GFP_KERNEL); intf = kzalloc(sizeof(*intf), GFP_KERNEL);
if (!intf) if (!intf)
return -ENOMEM; return -ENOMEM;
memset(intf, 0, sizeof(*intf));
intf->ipmi_version_major = ipmi_version_major(device_id); intf->ipmi_version_major = ipmi_version_major(device_id);
intf->ipmi_version_minor = ipmi_version_minor(device_id); intf->ipmi_version_minor = ipmi_version_minor(device_id);

View File

@ -540,13 +540,12 @@ static int mgslpc_probe(struct pcmcia_device *link)
if (debug_level >= DEBUG_LEVEL_INFO) if (debug_level >= DEBUG_LEVEL_INFO)
printk("mgslpc_attach\n"); printk("mgslpc_attach\n");
info = kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); info = kzalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
if (!info) { if (!info) {
printk("Error can't allocate device instance data\n"); printk("Error can't allocate device instance data\n");
return -ENOMEM; return -ENOMEM;
} }
memset(info, 0, sizeof(MGSLPC_INFO));
info->magic = MGSLPC_MAGIC; info->magic = MGSLPC_MAGIC;
INIT_WORK(&info->task, bh_handler); INIT_WORK(&info->task, bh_handler);
info->max_frame_size = 4096; info->max_frame_size = 4096;

View File

@ -803,9 +803,7 @@ static void *ckmalloc(int size)
{ {
void *p; void *p;
p = kmalloc(size, GFP_KERNEL); p = kzalloc(size, GFP_KERNEL);
if (p)
memset(p, 0, size);
return p; return p;
} }

View File

@ -556,9 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
{ {
struct CmdBlk *CmdBlkP; struct CmdBlk *CmdBlkP;
CmdBlkP = kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC); CmdBlkP = kzalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
if (CmdBlkP)
memset(CmdBlkP, 0, sizeof(struct CmdBlk));
return CmdBlkP; return CmdBlkP;
} }

View File

@ -863,8 +863,7 @@ int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
if (PortP->TxRingBuffer) if (PortP->TxRingBuffer)
memset(PortP->TxRingBuffer, 0, p->RIOBufferSize); memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
else if (p->RIOBufferSize) { else if (p->RIOBufferSize) {
PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL); PortP->TxRingBuffer = kzalloc(p->RIOBufferSize, GFP_KERNEL);
memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
} }
PortP->TxBufferOut = 0; PortP->TxBufferOut = 0;
PortP->TxBufferIn = 0; PortP->TxBufferIn = 0;

View File

@ -635,12 +635,11 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev)
ctlp = sCtlNumToCtlPtr(board); ctlp = sCtlNumToCtlPtr(board);
/* Get a r_port struct for the port, fill it in and save it globally, indexed by line number */ /* Get a r_port struct for the port, fill it in and save it globally, indexed by line number */
info = kmalloc(sizeof (struct r_port), GFP_KERNEL); info = kzalloc(sizeof (struct r_port), GFP_KERNEL);
if (!info) { if (!info) {
printk(KERN_INFO "Couldn't allocate info struct for line #%d\n", line); printk(KERN_INFO "Couldn't allocate info struct for line #%d\n", line);
return; return;
} }
memset(info, 0, sizeof (struct r_port));
info->magic = RPORT_MAGIC; info->magic = RPORT_MAGIC;
info->line = line; info->line = line;

View File

@ -4324,13 +4324,12 @@ static struct mgsl_struct* mgsl_allocate_device(void)
{ {
struct mgsl_struct *info; struct mgsl_struct *info;
info = kmalloc(sizeof(struct mgsl_struct), info = kzalloc(sizeof(struct mgsl_struct),
GFP_KERNEL); GFP_KERNEL);
if (!info) { if (!info) {
printk("Error can't allocate device instance data\n"); printk("Error can't allocate device instance data\n");
} else { } else {
memset(info, 0, sizeof(struct mgsl_struct));
info->magic = MGSL_MAGIC; info->magic = MGSL_MAGIC;
INIT_WORK(&info->task, mgsl_bh_handler); INIT_WORK(&info->task, mgsl_bh_handler);
info->max_frame_size = 4096; info->max_frame_size = 4096;

View File

@ -3414,13 +3414,12 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev
{ {
struct slgt_info *info; struct slgt_info *info;
info = kmalloc(sizeof(struct slgt_info), GFP_KERNEL); info = kzalloc(sizeof(struct slgt_info), GFP_KERNEL);
if (!info) { if (!info) {
DBGERR(("%s device alloc failed adapter=%d port=%d\n", DBGERR(("%s device alloc failed adapter=%d port=%d\n",
driver_name, adapter_num, port_num)); driver_name, adapter_num, port_num));
} else { } else {
memset(info, 0, sizeof(struct slgt_info));
info->magic = MGSL_MAGIC; info->magic = MGSL_MAGIC;
INIT_WORK(&info->task, bh_handler); INIT_WORK(&info->task, bh_handler);
info->max_frame_size = 4096; info->max_frame_size = 4096;

View File

@ -3786,14 +3786,13 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev)
{ {
SLMP_INFO *info; SLMP_INFO *info;
info = kmalloc(sizeof(SLMP_INFO), info = kzalloc(sizeof(SLMP_INFO),
GFP_KERNEL); GFP_KERNEL);
if (!info) { if (!info) {
printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n", printk("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n",
__FILE__,__LINE__, adapter_num, port_num); __FILE__,__LINE__, adapter_num, port_num);
} else { } else {
memset(info, 0, sizeof(SLMP_INFO));
info->magic = MGSL_MAGIC; info->magic = MGSL_MAGIC;
INIT_WORK(&info->task, bh_handler); INIT_WORK(&info->task, bh_handler);
info->max_frame_size = 4096; info->max_frame_size = 4096;

View File

@ -328,12 +328,11 @@ static int __devinit mpcore_wdt_probe(struct platform_device *dev)
goto err_out; goto err_out;
} }
wdt = kmalloc(sizeof(struct mpcore_wdt), GFP_KERNEL); wdt = kzalloc(sizeof(struct mpcore_wdt), GFP_KERNEL);
if (!wdt) { if (!wdt) {
ret = -ENOMEM; ret = -ENOMEM;
goto err_out; goto err_out;
} }
memset(wdt, 0, sizeof(struct mpcore_wdt));
wdt->dev = &dev->dev; wdt->dev = &dev->dev;
wdt->irq = platform_get_irq(dev, 0); wdt->irq = platform_get_irq(dev, 0);

View File

@ -626,12 +626,11 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe)); maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
/* allocate memory for our device and initialize it */ /* allocate memory for our device and initialize it */
usb_pcwd = kmalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL); usb_pcwd = kzalloc (sizeof(struct usb_pcwd_private), GFP_KERNEL);
if (usb_pcwd == NULL) { if (usb_pcwd == NULL) {
printk(KERN_ERR PFX "Out of memory\n"); printk(KERN_ERR PFX "Out of memory\n");
goto error; goto error;
} }
memset (usb_pcwd, 0x00, sizeof (*usb_pcwd));
usb_pcwd_device = usb_pcwd; usb_pcwd_device = usb_pcwd;

View File

@ -165,12 +165,11 @@ static int __devinit swarm_ide_init_module(void)
goto out; goto out;
} }
if (!(pldev = kmalloc(sizeof (*pldev), GFP_KERNEL))) { if (!(pldev = kzalloc(sizeof (*pldev), GFP_KERNEL))) {
err = -ENOMEM; err = -ENOMEM;
goto out_unregister_driver; goto out_unregister_driver;
} }
memset (pldev, 0, sizeof (*pldev));
pldev->name = swarm_ide_string; pldev->name = swarm_ide_string;
pldev->id = 0; pldev->id = 0;
pldev->dev.release = swarm_ide_platform_release; pldev->dev.release = swarm_ide_platform_release;

View File

@ -295,10 +295,9 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
struct addr_req *req; struct addr_req *req;
int ret = 0; int ret = 0;
req = kmalloc(sizeof *req, GFP_KERNEL); req = kzalloc(sizeof *req, GFP_KERNEL);
if (!req) if (!req)
return -ENOMEM; return -ENOMEM;
memset(req, 0, sizeof *req);
if (src_addr) if (src_addr)
memcpy(&req->src_addr, src_addr, ip_addr_size(src_addr)); memcpy(&req->src_addr, src_addr, ip_addr_size(src_addr));

View File

@ -229,9 +229,8 @@ static void *alloc_ep(int size, gfp_t gfp)
{ {
struct iwch_ep_common *epc; struct iwch_ep_common *epc;
epc = kmalloc(size, gfp); epc = kzalloc(size, gfp);
if (epc) { if (epc) {
memset(epc, 0, size);
kref_init(&epc->kref); kref_init(&epc->kref);
spin_lock_init(&epc->lock); spin_lock_init(&epc->lock);
init_waitqueue_head(&epc->waitq); init_waitqueue_head(&epc->waitq);

View File

@ -117,15 +117,13 @@ static int amba_kmi_probe(struct amba_device *dev, void *id)
if (ret) if (ret)
return ret; return ret;
kmi = kmalloc(sizeof(struct amba_kmi_port), GFP_KERNEL); kmi = kzalloc(sizeof(struct amba_kmi_port), GFP_KERNEL);
io = kmalloc(sizeof(struct serio), GFP_KERNEL); io = kzalloc(sizeof(struct serio), GFP_KERNEL);
if (!kmi || !io) { if (!kmi || !io) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
memset(kmi, 0, sizeof(struct amba_kmi_port));
memset(io, 0, sizeof(struct serio));
io->id.type = SERIO_8042; io->id.type = SERIO_8042;
io->write = amba_kmi_write; io->write = amba_kmi_write;

View File

@ -140,15 +140,13 @@ static int __devinit pcips2_probe(struct pci_dev *dev, const struct pci_device_i
if (ret) if (ret)
goto disable; goto disable;
ps2if = kmalloc(sizeof(struct pcips2_data), GFP_KERNEL); ps2if = kzalloc(sizeof(struct pcips2_data), GFP_KERNEL);
serio = kmalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
if (!ps2if || !serio) { if (!ps2if || !serio) {
ret = -ENOMEM; ret = -ENOMEM;
goto release; goto release;
} }
memset(ps2if, 0, sizeof(struct pcips2_data));
memset(serio, 0, sizeof(struct serio));
serio->id.type = SERIO_8042; serio->id.type = SERIO_8042;
serio->write = pcips2_write; serio->write = pcips2_write;

View File

@ -234,15 +234,13 @@ static int __devinit ps2_probe(struct sa1111_dev *dev)
struct serio *serio; struct serio *serio;
int ret; int ret;
ps2if = kmalloc(sizeof(struct ps2if), GFP_KERNEL); ps2if = kzalloc(sizeof(struct ps2if), GFP_KERNEL);
serio = kmalloc(sizeof(struct serio), GFP_KERNEL); serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
if (!ps2if || !serio) { if (!ps2if || !serio) {
ret = -ENOMEM; ret = -ENOMEM;
goto free; goto free;
} }
memset(ps2if, 0, sizeof(struct ps2if));
memset(serio, 0, sizeof(struct serio));
serio->id.type = SERIO_8042; serio->id.type = SERIO_8042;
serio->write = ps2_write; serio->write = ps2_write;

View File

@ -365,10 +365,9 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
if (np == NULL) if (np == NULL)
return NULL; return NULL;
dev = kmalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) if (!dev)
return NULL; return NULL;
memset(dev, 0, sizeof(*dev));
dev->bus = &chip->lbus; dev->bus = &chip->lbus;
dev->media_bay = in_bay; dev->media_bay = in_bay;

View File

@ -1053,10 +1053,9 @@ static int smu_open(struct inode *inode, struct file *file)
struct smu_private *pp; struct smu_private *pp;
unsigned long flags; unsigned long flags;
pp = kmalloc(sizeof(struct smu_private), GFP_KERNEL); pp = kzalloc(sizeof(struct smu_private), GFP_KERNEL);
if (pp == 0) if (pp == 0)
return -ENOMEM; return -ENOMEM;
memset(pp, 0, sizeof(struct smu_private));
spin_lock_init(&pp->lock); spin_lock_init(&pp->lock);
pp->mode = smu_file_commands; pp->mode = smu_file_commands;
init_waitqueue_head(&pp->wait); init_waitqueue_head(&pp->wait);

View File

@ -318,10 +318,9 @@ static struct i2c_client *attach_i2c_chip(int id, const char *name)
if (adap == NULL) if (adap == NULL)
return NULL; return NULL;
clt = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); clt = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (clt == NULL) if (clt == NULL)
return NULL; return NULL;
memset(clt, 0, sizeof(struct i2c_client));
clt->addr = (id >> 1) & 0x7f; clt->addr = (id >> 1) & 0x7f;
clt->adapter = adap; clt->adapter = adap;

View File

@ -431,9 +431,8 @@ do_probe( struct i2c_adapter *adapter, int addr, int kind )
| I2C_FUNC_SMBUS_WRITE_BYTE) ) | I2C_FUNC_SMBUS_WRITE_BYTE) )
return 0; return 0;
if( !(cl=kmalloc(sizeof(*cl), GFP_KERNEL)) ) if( !(cl=kzalloc(sizeof(*cl), GFP_KERNEL)) )
return -ENOMEM; return -ENOMEM;
memset( cl, 0, sizeof(struct i2c_client) );
cl->addr = addr; cl->addr = addr;
cl->adapter = adapter; cl->adapter = adapter;

View File

@ -117,10 +117,9 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
DBG("wf_lm75: creating %s device at address 0x%02x\n", DBG("wf_lm75: creating %s device at address 0x%02x\n",
ds1775 ? "ds1775" : "lm75", addr); ds1775 ? "ds1775" : "lm75", addr);
lm = kmalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL); lm = kzalloc(sizeof(struct wf_lm75_sensor), GFP_KERNEL);
if (lm == NULL) if (lm == NULL)
return NULL; return NULL;
memset(lm, 0, sizeof(struct wf_lm75_sensor));
/* Usual rant about sensor names not beeing very consistent in /* Usual rant about sensor names not beeing very consistent in
* the device-tree, oh well ... * the device-tree, oh well ...

View File

@ -951,13 +951,12 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
len = sizeof(*ms) + (sizeof(ms->mirror[0]) * nr_mirrors); len = sizeof(*ms) + (sizeof(ms->mirror[0]) * nr_mirrors);
ms = kmalloc(len, GFP_KERNEL); ms = kzalloc(len, GFP_KERNEL);
if (!ms) { if (!ms) {
ti->error = "Cannot allocate mirror context"; ti->error = "Cannot allocate mirror context";
return NULL; return NULL;
} }
memset(ms, 0, len);
spin_lock_init(&ms->lock); spin_lock_init(&ms->lock);
ms->ti = ti; ms->ti = ti;

View File

@ -905,12 +905,11 @@ static int cinergyt2_probe (struct usb_interface *intf,
struct cinergyt2 *cinergyt2; struct cinergyt2 *cinergyt2;
int err; int err;
if (!(cinergyt2 = kmalloc (sizeof(struct cinergyt2), GFP_KERNEL))) { if (!(cinergyt2 = kzalloc (sizeof(struct cinergyt2), GFP_KERNEL))) {
dprintk(1, "out of memory?!?\n"); dprintk(1, "out of memory?!?\n");
return -ENOMEM; return -ENOMEM;
} }
memset (cinergyt2, 0, sizeof (struct cinergyt2));
usb_set_intfdata (intf, (void *) cinergyt2); usb_set_intfdata (intf, (void *) cinergyt2);
mutex_init(&cinergyt2->sem); mutex_init(&cinergyt2->sem);

View File

@ -2224,15 +2224,13 @@ struct camera_data *cpia2_init_camera_struct(void)
{ {
struct camera_data *cam; struct camera_data *cam;
cam = kmalloc(sizeof(*cam), GFP_KERNEL); cam = kzalloc(sizeof(*cam), GFP_KERNEL);
if (!cam) { if (!cam) {
ERR("couldn't kmalloc cpia2 struct\n"); ERR("couldn't kmalloc cpia2 struct\n");
return NULL; return NULL;
} }
/* Default everything to 0 */
memset(cam, 0, sizeof(struct camera_data));
cam->present = 1; cam->present = 1;
mutex_init(&cam->busy_lock); mutex_init(&cam->busy_lock);

View File

@ -812,10 +812,9 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
int msp_product, msp_prod_hi, msp_prod_lo; int msp_product, msp_prod_hi, msp_prod_lo;
int msp_rom; int msp_rom;
client = kmalloc(sizeof(*client), GFP_KERNEL); client = kzalloc(sizeof(*client), GFP_KERNEL);
if (client == NULL) if (client == NULL)
return -ENOMEM; return -ENOMEM;
memset(client, 0, sizeof(*client));
client->addr = address; client->addr = address;
client->adapter = adapter; client->adapter = adapter;
client->driver = &i2c_driver; client->driver = &i2c_driver;

View File

@ -353,9 +353,8 @@ static int planb_prepare_open(struct planb *pb)
* PLANB_DUMMY)*sizeof(struct dbdma_cmd) * PLANB_DUMMY)*sizeof(struct dbdma_cmd)
+(PLANB_MAXLINES*((PLANB_MAXPIXELS+7)& ~7))/8 +(PLANB_MAXLINES*((PLANB_MAXPIXELS+7)& ~7))/8
+MAX_GBUFFERS*sizeof(unsigned int); +MAX_GBUFFERS*sizeof(unsigned int);
if ((pb->priv_space = kmalloc (size, GFP_KERNEL)) == 0) if ((pb->priv_space = kzalloc (size, GFP_KERNEL)) == 0)
return -ENOMEM; return -ENOMEM;
memset ((void *) pb->priv_space, 0, size);
pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *) pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *)
DBDMA_ALIGN (pb->priv_space); DBDMA_ALIGN (pb->priv_space);
pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size; pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size;

View File

@ -1130,13 +1130,12 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
} }
if ((cam = if ((cam =
kmalloc(sizeof (struct vicam_camera), GFP_KERNEL)) == NULL) { kzalloc(sizeof (struct vicam_camera), GFP_KERNEL)) == NULL) {
printk(KERN_WARNING printk(KERN_WARNING
"could not allocate kernel memory for vicam_camera struct\n"); "could not allocate kernel memory for vicam_camera struct\n");
return -ENOMEM; return -ENOMEM;
} }
memset(cam, 0, sizeof (struct vicam_camera));
cam->shutter_speed = 15; cam->shutter_speed = 15;

View File

@ -200,9 +200,8 @@ struct mcp *mcp_host_alloc(struct device *parent, size_t size)
{ {
struct mcp *mcp; struct mcp *mcp;
mcp = kmalloc(sizeof(struct mcp) + size, GFP_KERNEL); mcp = kzalloc(sizeof(struct mcp) + size, GFP_KERNEL);
if (mcp) { if (mcp) {
memset(mcp, 0, sizeof(struct mcp) + size);
spin_lock_init(&mcp->lock); spin_lock_init(&mcp->lock);
mcp->attached_device.parent = parent; mcp->attached_device.parent = parent;
mcp->attached_device.bus = &mcp_bus_type; mcp->attached_device.bus = &mcp_bus_type;

View File

@ -484,12 +484,11 @@ static int ucb1x00_probe(struct mcp *mcp)
goto err_disable; goto err_disable;
} }
ucb = kmalloc(sizeof(struct ucb1x00), GFP_KERNEL); ucb = kzalloc(sizeof(struct ucb1x00), GFP_KERNEL);
ret = -ENOMEM; ret = -ENOMEM;
if (!ucb) if (!ucb)
goto err_disable; goto err_disable;
memset(ucb, 0, sizeof(struct ucb1x00));
ucb->cdev.class = &ucb1x00_class; ucb->cdev.class = &ucb1x00_class;
ucb->cdev.dev = &mcp->attached_device; ucb->cdev.dev = &mcp->attached_device;

View File

@ -979,10 +979,9 @@ static int asus_hotk_add(struct acpi_device *device)
printk(ASUS_NOTICE "Asus Laptop Support version %s\n", printk(ASUS_NOTICE "Asus Laptop Support version %s\n",
ASUS_LAPTOP_VERSION); ASUS_LAPTOP_VERSION);
hotk = kmalloc(sizeof(struct asus_hotk), GFP_KERNEL); hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
if (!hotk) if (!hotk)
return -ENOMEM; return -ENOMEM;
memset(hotk, 0, sizeof(struct asus_hotk));
hotk->handle = device->handle; hotk->handle = device->handle;
strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME); strcpy(acpi_device_name(device), ASUS_HOTK_DEVICE_NAME);

View File

@ -41,18 +41,16 @@ struct command *ibmasm_new_command(struct service_processor *sp, size_t buffer_s
if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE) if (buffer_size > IBMASM_CMD_MAX_BUFFER_SIZE)
return NULL; return NULL;
cmd = kmalloc(sizeof(struct command), GFP_KERNEL); cmd = kzalloc(sizeof(struct command), GFP_KERNEL);
if (cmd == NULL) if (cmd == NULL)
return NULL; return NULL;
memset(cmd, 0, sizeof(*cmd));
cmd->buffer = kmalloc(buffer_size, GFP_KERNEL); cmd->buffer = kzalloc(buffer_size, GFP_KERNEL);
if (cmd->buffer == NULL) { if (cmd->buffer == NULL) {
kfree(cmd); kfree(cmd);
return NULL; return NULL;
} }
memset(cmd->buffer, 0, buffer_size);
cmd->buffer_size = buffer_size; cmd->buffer_size = buffer_size;
kobject_init(&cmd->kobj); kobject_init(&cmd->kobj);

View File

@ -563,11 +563,10 @@ static ssize_t remote_settings_file_write(struct file *file, const char __user *
if (*offset != 0) if (*offset != 0)
return 0; return 0;
buff = kmalloc (count + 1, GFP_KERNEL); buff = kzalloc (count + 1, GFP_KERNEL);
if (!buff) if (!buff)
return -ENOMEM; return -ENOMEM;
memset(buff, 0x0, count + 1);
if (copy_from_user(buff, ubuff, count)) { if (copy_from_user(buff, ubuff, count)) {
kfree(buff); kfree(buff);

View File

@ -77,13 +77,12 @@ static int __devinit ibmasm_init_one(struct pci_dev *pdev, const struct pci_devi
/* vnc client won't work without bus-mastering */ /* vnc client won't work without bus-mastering */
pci_set_master(pdev); pci_set_master(pdev);
sp = kmalloc(sizeof(struct service_processor), GFP_KERNEL); sp = kzalloc(sizeof(struct service_processor), GFP_KERNEL);
if (sp == NULL) { if (sp == NULL) {
dev_err(&pdev->dev, "Failed to allocate memory\n"); dev_err(&pdev->dev, "Failed to allocate memory\n");
result = -ENOMEM; result = -ENOMEM;
goto error_kmalloc; goto error_kmalloc;
} }
memset(sp, 0, sizeof(struct service_processor));
spin_lock_init(&sp->lock); spin_lock_init(&sp->lock);
INIT_LIST_HEAD(&sp->command_queue); INIT_LIST_HEAD(&sp->command_queue);

View File

@ -414,13 +414,12 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
return ERR_PTR(-ENOSPC); return ERR_PTR(-ENOSPC);
__set_bit(devidx, dev_use); __set_bit(devidx, dev_use);
md = kmalloc(sizeof(struct mmc_blk_data), GFP_KERNEL); md = kzalloc(sizeof(struct mmc_blk_data), GFP_KERNEL);
if (!md) { if (!md) {
ret = -ENOMEM; ret = -ENOMEM;
goto out; goto out;
} }
memset(md, 0, sizeof(struct mmc_blk_data));
/* /*
* Set the read-only status based on the supported commands * Set the read-only status based on the supported commands

View File

@ -1519,14 +1519,13 @@ static void b44_setup_pseudo_magicp(struct b44 *bp)
u8 *pwol_pattern; u8 *pwol_pattern;
u8 pwol_mask[B44_PMASK_SIZE]; u8 pwol_mask[B44_PMASK_SIZE];
pwol_pattern = kmalloc(B44_PATTERN_SIZE, GFP_KERNEL); pwol_pattern = kzalloc(B44_PATTERN_SIZE, GFP_KERNEL);
if (!pwol_pattern) { if (!pwol_pattern) {
printk(KERN_ERR PFX "Memory not available for WOL\n"); printk(KERN_ERR PFX "Memory not available for WOL\n");
return; return;
} }
/* Ipv4 magic packet pattern - pattern 0.*/ /* Ipv4 magic packet pattern - pattern 0.*/
memset(pwol_pattern, 0, B44_PATTERN_SIZE);
memset(pwol_mask, 0, B44_PMASK_SIZE); memset(pwol_mask, 0, B44_PMASK_SIZE);
plen0 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask, plen0 = b44_magic_pattern(bp->dev->dev_addr, pwol_pattern, pwol_mask,
B44_ETHIPV4UDP_HLEN); B44_ETHIPV4UDP_HLEN);

View File

@ -395,14 +395,13 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
* Allocate the main control structure for this instance. * Allocate the main control structure for this instance.
*/ */
maxmaxcode = MAXCODE(bits); maxmaxcode = MAXCODE(bits);
db = kmalloc(sizeof (struct bsd_db), db = kzalloc(sizeof (struct bsd_db),
GFP_KERNEL); GFP_KERNEL);
if (!db) if (!db)
{ {
return NULL; return NULL;
} }
memset (db, 0, sizeof(struct bsd_db));
/* /*
* Allocate space for the dictionary. This may be more than one page in * Allocate space for the dictionary. This may be more than one page in
* length. * length.

View File

@ -5137,12 +5137,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
goto out_unmap; goto out_unmap;
np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size]; np->tx_ring.ex = &np->rx_ring.ex[np->rx_ring_size];
} }
np->rx_skb = kmalloc(sizeof(struct nv_skb_map) * np->rx_ring_size, GFP_KERNEL); np->rx_skb = kcalloc(np->rx_ring_size, sizeof(struct nv_skb_map), GFP_KERNEL);
np->tx_skb = kmalloc(sizeof(struct nv_skb_map) * np->tx_ring_size, GFP_KERNEL); np->tx_skb = kcalloc(np->tx_ring_size, sizeof(struct nv_skb_map), GFP_KERNEL);
if (!np->rx_skb || !np->tx_skb) if (!np->rx_skb || !np->tx_skb)
goto out_freering; goto out_freering;
memset(np->rx_skb, 0, sizeof(struct nv_skb_map) * np->rx_ring_size);
memset(np->tx_skb, 0, sizeof(struct nv_skb_map) * np->tx_ring_size);
dev->open = nv_open; dev->open = nv_open;
dev->stop = nv_close; dev->stop = nv_close;

View File

@ -453,8 +453,8 @@ static int __init setup_adapter(int card_base, int type, int n)
int scc_base = card_base + hw[type].scc_offset; int scc_base = card_base + hw[type].scc_offset;
char *chipnames[] = CHIPNAMES; char *chipnames[] = CHIPNAMES;
/* Allocate memory */ /* Initialize what is necessary for write_scc and write_scc_data */
info = kmalloc(sizeof(struct scc_info), GFP_KERNEL | GFP_DMA); info = kzalloc(sizeof(struct scc_info), GFP_KERNEL | GFP_DMA);
if (!info) { if (!info) {
printk(KERN_ERR "dmascc: " printk(KERN_ERR "dmascc: "
"could not allocate memory for %s at %#3x\n", "could not allocate memory for %s at %#3x\n",
@ -462,8 +462,6 @@ static int __init setup_adapter(int card_base, int type, int n)
goto out; goto out;
} }
/* Initialize what is necessary for write_scc and write_scc_data */
memset(info, 0, sizeof(struct scc_info));
info->dev[0] = alloc_netdev(0, "", dev_setup); info->dev[0] = alloc_netdev(0, "", dev_setup);
if (!info->dev[0]) { if (!info->dev[0]) {

View File

@ -164,14 +164,13 @@ irport_open(int i, unsigned int iobase, unsigned int irq)
/* Allocate memory if needed */ /* Allocate memory if needed */
if (self->tx_buff.truesize > 0) { if (self->tx_buff.truesize > 0) {
self->tx_buff.head = kmalloc(self->tx_buff.truesize, self->tx_buff.head = kzalloc(self->tx_buff.truesize,
GFP_KERNEL); GFP_KERNEL);
if (self->tx_buff.head == NULL) { if (self->tx_buff.head == NULL) {
IRDA_ERROR("%s(), can't allocate memory for " IRDA_ERROR("%s(), can't allocate memory for "
"transmit buffer!\n", __FUNCTION__); "transmit buffer!\n", __FUNCTION__);
goto err_out4; goto err_out4;
} }
memset(self->tx_buff.head, 0, self->tx_buff.truesize);
} }
self->tx_buff.data = self->tx_buff.head; self->tx_buff.data = self->tx_buff.head;

View File

@ -505,10 +505,9 @@ static int irtty_open(struct tty_struct *tty)
} }
/* allocate private device info block */ /* allocate private device info block */
priv = kmalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
goto out_put; goto out_put;
memset(priv, 0, sizeof(*priv));
priv->magic = IRTTY_MAGIC; priv->magic = IRTTY_MAGIC;
priv->tty = tty; priv->tty = tty;

View File

@ -822,10 +822,9 @@ static int veth_init_connection(u8 rlp)
|| ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) ) || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) )
return 0; return 0;
cnx = kmalloc(sizeof(*cnx), GFP_KERNEL); cnx = kzalloc(sizeof(*cnx), GFP_KERNEL);
if (! cnx) if (! cnx)
return -ENOMEM; return -ENOMEM;
memset(cnx, 0, sizeof(*cnx));
cnx->remote_lp = rlp; cnx->remote_lp = rlp;
spin_lock_init(&cnx->lock); spin_lock_init(&cnx->lock);
@ -852,14 +851,13 @@ static int veth_init_connection(u8 rlp)
if (rc != 0) if (rc != 0)
return rc; return rc;
msgs = kmalloc(VETH_NUMBUFFERS * sizeof(struct veth_msg), GFP_KERNEL); msgs = kcalloc(VETH_NUMBUFFERS, sizeof(struct veth_msg), GFP_KERNEL);
if (! msgs) { if (! msgs) {
veth_error("Can't allocate buffers for LPAR %d.\n", rlp); veth_error("Can't allocate buffers for LPAR %d.\n", rlp);
return -ENOMEM; return -ENOMEM;
} }
cnx->msgs = msgs; cnx->msgs = msgs;
memset(msgs, 0, VETH_NUMBUFFERS * sizeof(struct veth_msg));
for (i = 0; i < VETH_NUMBUFFERS; i++) { for (i = 0; i < VETH_NUMBUFFERS; i++) {
msgs[i].token = i; msgs[i].token = i;

View File

@ -533,11 +533,10 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
/* Make certain the data structures used by the LANCE are aligned and DMAble. */ /* Make certain the data structures used by the LANCE are aligned and DMAble. */
lp = kmalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL); lp = kzalloc(sizeof(*lp), GFP_DMA | GFP_KERNEL);
if(lp==NULL) if(lp==NULL)
return -ENODEV; return -ENODEV;
if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp);
memset(lp, 0, sizeof(*lp));
dev->priv = lp; dev->priv = lp;
lp->name = chipname; lp->name = chipname;
lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE, lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE,

View File

@ -147,7 +147,7 @@ static int com20020_probe(struct pcmcia_device *p_dev)
DEBUG(0, "com20020_attach()\n"); DEBUG(0, "com20020_attach()\n");
/* Create new network device */ /* Create new network device */
info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
if (!info) if (!info)
goto fail_alloc_info; goto fail_alloc_info;
@ -155,7 +155,6 @@ static int com20020_probe(struct pcmcia_device *p_dev)
if (!dev) if (!dev)
goto fail_alloc_dev; goto fail_alloc_dev;
memset(info, 0, sizeof(struct com20020_dev_t));
lp = dev->priv; lp = dev->priv;
lp->timeout = timeout; lp->timeout = timeout;
lp->backplane = backplane; lp->backplane = backplane;

View File

@ -146,9 +146,8 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link)
DEBUG(0, "ibmtr_attach()\n"); DEBUG(0, "ibmtr_attach()\n");
/* Create new token-ring device */ /* Create new token-ring device */
info = kmalloc(sizeof(*info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) return -ENOMEM; if (!info) return -ENOMEM;
memset(info,0,sizeof(*info));
dev = alloc_trdev(sizeof(struct tok_info)); dev = alloc_trdev(sizeof(struct tok_info));
if (!dev) { if (!dev) {
kfree(info); kfree(info);

View File

@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *tty)
int err; int err;
err = -ENOMEM; err = -ENOMEM;
ap = kmalloc(sizeof(*ap), GFP_KERNEL); ap = kzalloc(sizeof(*ap), GFP_KERNEL);
if (ap == 0) if (ap == 0)
goto out; goto out;
/* initialize the asyncppp structure */ /* initialize the asyncppp structure */
memset(ap, 0, sizeof(*ap));
ap->tty = tty; ap->tty = tty;
ap->mru = PPP_MRU; ap->mru = PPP_MRU;
spin_lock_init(&ap->xmit_lock); spin_lock_init(&ap->xmit_lock);

View File

@ -121,12 +121,11 @@ static void *z_comp_alloc(unsigned char *options, int opt_len)
if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
return NULL; return NULL;
state = kmalloc(sizeof(*state), state = kzalloc(sizeof(*state),
GFP_KERNEL); GFP_KERNEL);
if (state == NULL) if (state == NULL)
return NULL; return NULL;
memset (state, 0, sizeof (struct ppp_deflate_state));
state->strm.next_in = NULL; state->strm.next_in = NULL;
state->w_size = w_size; state->w_size = w_size;
state->strm.workspace = vmalloc(zlib_deflate_workspacesize()); state->strm.workspace = vmalloc(zlib_deflate_workspacesize());
@ -341,11 +340,10 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len)
if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE) if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
return NULL; return NULL;
state = kmalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) if (state == NULL)
return NULL; return NULL;
memset (state, 0, sizeof (struct ppp_deflate_state));
state->w_size = w_size; state->w_size = w_size;
state->strm.next_out = NULL; state->strm.next_out = NULL;
state->strm.workspace = kmalloc(zlib_inflate_workspacesize(), state->strm.workspace = kmalloc(zlib_inflate_workspacesize(),

View File

@ -200,11 +200,10 @@ static void *mppe_alloc(unsigned char *options, int optlen)
|| options[0] != CI_MPPE || options[1] != CILEN_MPPE) || options[0] != CI_MPPE || options[1] != CILEN_MPPE)
goto out; goto out;
state = kmalloc(sizeof(*state), GFP_KERNEL); state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) if (state == NULL)
goto out; goto out;
memset(state, 0, sizeof(*state));
state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); state->arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(state->arc4)) { if (IS_ERR(state->arc4)) {

View File

@ -207,13 +207,12 @@ ppp_sync_open(struct tty_struct *tty)
struct syncppp *ap; struct syncppp *ap;
int err; int err;
ap = kmalloc(sizeof(*ap), GFP_KERNEL); ap = kzalloc(sizeof(*ap), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (ap == 0) if (ap == 0)
goto out; goto out;
/* initialize the syncppp structure */ /* initialize the syncppp structure */
memset(ap, 0, sizeof(*ap));
ap->tty = tty; ap->tty = tty;
ap->mru = PPP_MRU; ap->mru = PPP_MRU;
spin_lock_init(&ap->xmit_lock); spin_lock_init(&ap->xmit_lock);

View File

@ -600,10 +600,9 @@ static int __init shaper_init(void)
return -ENODEV; return -ENODEV;
alloc_size = sizeof(*dev) * shapers; alloc_size = sizeof(*dev) * shapers;
devs = kmalloc(alloc_size, GFP_KERNEL); devs = kzalloc(alloc_size, GFP_KERNEL);
if (!devs) if (!devs)
return -ENOMEM; return -ENOMEM;
memset(devs, 0, alloc_size);
for (i = 0; i < shapers; i++) { for (i = 0; i < shapers; i++) {

View File

@ -315,12 +315,11 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
return -ENODEV; return -ENODEV;
} }
card = kmalloc(sizeof(card_t), GFP_KERNEL); card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk(KERN_ERR "c101: unable to allocate memory\n"); printk(KERN_ERR "c101: unable to allocate memory\n");
return -ENOBUFS; return -ENOBUFS;
} }
memset(card, 0, sizeof(card_t));
card->dev = alloc_hdlcdev(card); card->dev = alloc_hdlcdev(card);
if (!card->dev) { if (!card->dev) {

View File

@ -572,13 +572,11 @@ static int cosa_probe(int base, int irq, int dma)
sprintf(cosa->name, "cosa%d", cosa->num); sprintf(cosa->name, "cosa%d", cosa->num);
/* Initialize the per-channel data */ /* Initialize the per-channel data */
cosa->chan = kmalloc(sizeof(struct channel_data)*cosa->nchannels, cosa->chan = kcalloc(cosa->nchannels, sizeof(struct channel_data), GFP_KERNEL);
GFP_KERNEL);
if (!cosa->chan) { if (!cosa->chan) {
err = -ENOMEM; err = -ENOMEM;
goto err_out3; goto err_out3;
} }
memset(cosa->chan, 0, sizeof(struct channel_data)*cosa->nchannels);
for (i=0; i<cosa->nchannels; i++) { for (i=0; i<cosa->nchannels; i++) {
cosa->chan[i].cosa = cosa; cosa->chan[i].cosa = cosa;
cosa->chan[i].num = i; cosa->chan[i].num = i;

View File

@ -113,12 +113,10 @@ static int __init cycx_init(void)
/* Verify number of cards and allocate adapter data space */ /* Verify number of cards and allocate adapter data space */
cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS); cycx_ncards = min_t(int, cycx_ncards, CYCX_MAX_CARDS);
cycx_ncards = max_t(int, cycx_ncards, 1); cycx_ncards = max_t(int, cycx_ncards, 1);
cycx_card_array = kmalloc(sizeof(struct cycx_device) * cycx_ncards, cycx_card_array = kcalloc(cycx_ncards, sizeof(struct cycx_device), GFP_KERNEL);
GFP_KERNEL);
if (!cycx_card_array) if (!cycx_card_array)
goto out; goto out;
memset(cycx_card_array, 0, sizeof(struct cycx_device) * cycx_ncards);
/* Register adapters with WAN router */ /* Register adapters with WAN router */
for (cnt = 0; cnt < cycx_ncards; ++cnt) { for (cnt = 0; cnt < cycx_ncards; ++cnt) {

View File

@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_device *wandev, struct net_device *dev,
} }
/* allocate and initialize private data */ /* allocate and initialize private data */
chan = kmalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL); chan = kzalloc(sizeof(struct cycx_x25_channel), GFP_KERNEL);
if (!chan) if (!chan)
return -ENOMEM; return -ENOMEM;
memset(chan, 0, sizeof(*chan));
strcpy(chan->name, conf->name); strcpy(chan->name, conf->name);
chan->card = card; chan->card = card;
chan->link = conf->port; chan->link = conf->port;

View File

@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
struct dscc4_dev_priv *root; struct dscc4_dev_priv *root;
int i, ret = -ENOMEM; int i, ret = -ENOMEM;
root = kmalloc(dev_per_card*sizeof(*root), GFP_KERNEL); root = kcalloc(dev_per_card, sizeof(*root), GFP_KERNEL);
if (!root) { if (!root) {
printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME); printk(KERN_ERR "%s: can't allocate data\n", DRV_NAME);
goto err_out; goto err_out;
} }
memset(root, 0, dev_per_card*sizeof(*root));
for (i = 0; i < dev_per_card; i++) { for (i = 0; i < dev_per_card; i++) {
root[i].dev = alloc_hdlcdev(root + i); root[i].dev = alloc_hdlcdev(root + i);
@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
goto err_free_dev; goto err_free_dev;
} }
ppriv = kmalloc(sizeof(*ppriv), GFP_KERNEL); ppriv = kzalloc(sizeof(*ppriv), GFP_KERNEL);
if (!ppriv) { if (!ppriv) {
printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME); printk(KERN_ERR "%s: can't allocate private data\n", DRV_NAME);
goto err_free_dev; goto err_free_dev;
} }
memset(ppriv, 0, sizeof(struct dscc4_pci_priv));
ppriv->root = root; ppriv->root = root;
spin_lock_init(&ppriv->lock); spin_lock_init(&ppriv->lock);

View File

@ -2476,13 +2476,12 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
} }
/* Allocate driver private data */ /* Allocate driver private data */
card = kmalloc(sizeof (struct fst_card_info), GFP_KERNEL); card = kzalloc(sizeof (struct fst_card_info), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk_err("FarSync card found but insufficient memory for" printk_err("FarSync card found but insufficient memory for"
" driver storage\n"); " driver storage\n");
return -ENOMEM; return -ENOMEM;
} }
memset(card, 0, sizeof (struct fst_card_info));
/* Try to enable the device */ /* Try to enable the device */
if ((err = pci_enable_device(pdev)) != 0) { if ((err = pci_enable_device(pdev)) != 0) {

View File

@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(int iobase, int irq)
return NULL; return NULL;
} }
sv = kmalloc(sizeof(struct sv11_device), GFP_KERNEL); sv = kzalloc(sizeof(struct sv11_device), GFP_KERNEL);
if(!sv) if(!sv)
goto fail3; goto fail3;
memset(sv, 0, sizeof(*sv));
sv->if_ptr=&sv->netdev; sv->if_ptr=&sv->netdev;
sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup); sv->netdev.dev = alloc_netdev(0, "hdlc%d", sv11_setup);

View File

@ -351,12 +351,11 @@ static int __init n2_run(unsigned long io, unsigned long irq,
return -ENODEV; return -ENODEV;
} }
card = kmalloc(sizeof(card_t), GFP_KERNEL); card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk(KERN_ERR "n2: unable to allocate memory\n"); printk(KERN_ERR "n2: unable to allocate memory\n");
return -ENOBUFS; return -ENOBUFS;
} }
memset(card, 0, sizeof(card_t));
card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);

View File

@ -3456,7 +3456,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if ((err = pci_enable_device(pdev)) < 0) if ((err = pci_enable_device(pdev)) < 0)
return err; return err;
card = kmalloc(sizeof(pc300_t), GFP_KERNEL); card = kzalloc(sizeof(pc300_t), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk("PC300 found at RAM 0x%016llx, " printk("PC300 found at RAM 0x%016llx, "
"but could not allocate card structure.\n", "but could not allocate card structure.\n",
@ -3464,7 +3464,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
err = -ENOMEM; err = -ENOMEM;
goto err_disable_dev; goto err_disable_dev;
} }
memset(card, 0, sizeof(pc300_t));
err = -ENODEV; err = -ENODEV;

View File

@ -334,14 +334,13 @@ static int __devinit pc300_pci_init_one(struct pci_dev *pdev,
return i; return i;
} }
card = kmalloc(sizeof(card_t), GFP_KERNEL); card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk(KERN_ERR "pc300: unable to allocate memory\n"); printk(KERN_ERR "pc300: unable to allocate memory\n");
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
return -ENOBUFS; return -ENOBUFS;
} }
memset(card, 0, sizeof(card_t));
pci_set_drvdata(pdev, card); pci_set_drvdata(pdev, card);
if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 || if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 ||

View File

@ -312,14 +312,13 @@ static int __devinit pci200_pci_init_one(struct pci_dev *pdev,
return i; return i;
} }
card = kmalloc(sizeof(card_t), GFP_KERNEL); card = kzalloc(sizeof(card_t), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk(KERN_ERR "pci200syn: unable to allocate memory\n"); printk(KERN_ERR "pci200syn: unable to allocate memory\n");
pci_release_regions(pdev); pci_release_regions(pdev);
pci_disable_device(pdev); pci_disable_device(pdev);
return -ENOBUFS; return -ENOBUFS;
} }
memset(card, 0, sizeof(card_t));
pci_set_drvdata(pdev, card); pci_set_drvdata(pdev, card);
card->ports[0].dev = alloc_hdlcdev(&card->ports[0]); card->ports[0].dev = alloc_hdlcdev(&card->ports[0]);
card->ports[1].dev = alloc_hdlcdev(&card->ports[1]); card->ports[1].dev = alloc_hdlcdev(&card->ports[1]);

View File

@ -1196,10 +1196,9 @@ static int sdla_xfer(struct net_device *dev, struct sdla_mem __user *info, int r
if (read) if (read)
{ {
temp = kmalloc(mem.len, GFP_KERNEL); temp = kzalloc(mem.len, GFP_KERNEL);
if (!temp) if (!temp)
return(-ENOMEM); return(-ENOMEM);
memset(temp, 0, mem.len);
sdla_read(dev, mem.addr, temp, mem.len); sdla_read(dev, mem.addr, temp, mem.len);
if(copy_to_user(mem.data, temp, mem.len)) if(copy_to_user(mem.data, temp, mem.len))
{ {

View File

@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_init(int iobase, int irq,
return NULL; return NULL;
} }
b = kmalloc(sizeof(struct slvl_board), GFP_KERNEL); b = kzalloc(sizeof(struct slvl_board), GFP_KERNEL);
if(!b) if(!b)
goto fail3; goto fail3;
memset(b, 0, sizeof(*b));
if (!(b->dev[0]= slvl_alloc(iobase, irq))) if (!(b->dev[0]= slvl_alloc(iobase, irq)))
goto fail2; goto fail2;

View File

@ -599,7 +599,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
} }
alloc_size = sizeof(card_t) + ports * sizeof(port_t); alloc_size = sizeof(card_t) + ports * sizeof(port_t);
card = kmalloc(alloc_size, GFP_KERNEL); card = kzalloc(alloc_size, GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk(KERN_ERR "wanXL %s: unable to allocate memory\n", printk(KERN_ERR "wanXL %s: unable to allocate memory\n",
pci_name(pdev)); pci_name(pdev));
@ -607,7 +607,6 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
pci_disable_device(pdev); pci_disable_device(pdev);
return -ENOBUFS; return -ENOBUFS;
} }
memset(card, 0, alloc_size);
pci_set_drvdata(pdev, card); pci_set_drvdata(pdev, card);
card->pdev = pdev; card->pdev = pdev;

View File

@ -786,14 +786,12 @@ static int __init init_x25_asy(void)
printk(KERN_INFO "X.25 async: version 0.00 ALPHA " printk(KERN_INFO "X.25 async: version 0.00 ALPHA "
"(dynamic channels, max=%d).\n", x25_asy_maxdev ); "(dynamic channels, max=%d).\n", x25_asy_maxdev );
x25_asy_devs = kmalloc(sizeof(struct net_device *)*x25_asy_maxdev, x25_asy_devs = kcalloc(x25_asy_maxdev, sizeof(struct net_device*), GFP_KERNEL);
GFP_KERNEL);
if (!x25_asy_devs) { if (!x25_asy_devs) {
printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " printk(KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] "
"array! Uaargh! (-> No X.25 available)\n"); "array! Uaargh! (-> No X.25 available)\n");
return -ENOMEM; return -ENOMEM;
} }
memset(x25_asy_devs, 0, sizeof(struct net_device *)*x25_asy_maxdev);
return tty_register_ldisc(N_X25, &x25_ldisc); return tty_register_ldisc(N_X25, &x25_ldisc);
} }

View File

@ -466,9 +466,8 @@ static struct nubus_dev* __init
parent->base, dir.base); parent->base, dir.base);
/* Actually we should probably panic if this fails */ /* Actually we should probably panic if this fails */
if ((dev = kmalloc(sizeof(*dev), GFP_ATOMIC)) == NULL) if ((dev = kzalloc(sizeof(*dev), GFP_ATOMIC)) == NULL)
return NULL; return NULL;
memset(dev, 0, sizeof(*dev));
dev->resid = parent->type; dev->resid = parent->type;
dev->directory = dir.base; dev->directory = dir.base;
dev->board = board; dev->board = board;
@ -800,9 +799,8 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
nubus_rewind(&rp, FORMAT_BLOCK_SIZE, bytelanes); nubus_rewind(&rp, FORMAT_BLOCK_SIZE, bytelanes);
/* Actually we should probably panic if this fails */ /* Actually we should probably panic if this fails */
if ((board = kmalloc(sizeof(*board), GFP_ATOMIC)) == NULL) if ((board = kzalloc(sizeof(*board), GFP_ATOMIC)) == NULL)
return NULL; return NULL;
memset(board, 0, sizeof(*board));
board->fblock = rp; board->fblock = rp;
/* Dump the format block for debugging purposes */ /* Dump the format block for debugging purposes */

View File

@ -105,9 +105,8 @@ static int parport_probe(struct pcmcia_device *link)
DEBUG(0, "parport_attach()\n"); DEBUG(0, "parport_attach()\n");
/* Create new parport device */ /* Create new parport device */
info = kmalloc(sizeof(*info), GFP_KERNEL); info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info) return -ENOMEM; if (!info) return -ENOMEM;
memset(info, 0, sizeof(*info));
link->priv = info; link->priv = info;
info->p_dev = link; info->p_dev = link;

View File

@ -324,10 +324,9 @@ static int __devinit parport_serial_pci_probe (struct pci_dev *dev,
struct parport_serial_private *priv; struct parport_serial_private *priv;
int err; int err;
priv = kmalloc (sizeof *priv, GFP_KERNEL); priv = kzalloc (sizeof *priv, GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
memset(priv, 0, sizeof(struct parport_serial_private));
pci_set_drvdata (dev, priv); pci_set_drvdata (dev, priv);
err = pci_enable_device (dev); err = pci_enable_device (dev);

View File

@ -148,11 +148,10 @@ static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
{ {
struct aer_rpc *rpc; struct aer_rpc *rpc;
if (!(rpc = kmalloc(sizeof(struct aer_rpc), if (!(rpc = kzalloc(sizeof(struct aer_rpc),
GFP_KERNEL))) GFP_KERNEL)))
return NULL; return NULL;
memset(rpc, 0, sizeof(struct aer_rpc));
/* /*
* Initialize Root lock access, e_lock, to Root Error Status Reg, * Initialize Root lock access, e_lock, to Root Error Status Reg,
* Root Error ID Reg, and Root error producer/consumer index. * Root Error ID Reg, and Root error producer/consumer index.

View File

@ -35,12 +35,11 @@ void *pnp_alloc(long size)
{ {
void *result; void *result;
result = kmalloc(size, GFP_KERNEL); result = kzalloc(size, GFP_KERNEL);
if (!result){ if (!result){
printk(KERN_ERR "pnp: Out of Memory\n"); printk(KERN_ERR "pnp: Out of Memory\n");
return NULL; return NULL;
} }
memset(result, 0, size);
return result; return result;
} }

View File

@ -297,11 +297,10 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
struct rio_switch *rswitch; struct rio_switch *rswitch;
int result, rdid; int result, rdid;
rdev = kmalloc(sizeof(struct rio_dev), GFP_KERNEL); rdev = kzalloc(sizeof(struct rio_dev), GFP_KERNEL);
if (!rdev) if (!rdev)
goto out; goto out;
memset(rdev, 0, sizeof(struct rio_dev));
rdev->net = net; rdev->net = net;
rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR, rio_mport_read_config_32(port, destid, hopcount, RIO_DEV_ID_CAR,
&result); &result);
@ -801,9 +800,8 @@ static struct rio_net __devinit *rio_alloc_net(struct rio_mport *port)
{ {
struct rio_net *net; struct rio_net *net;
net = kmalloc(sizeof(struct rio_net), GFP_KERNEL); net = kzalloc(sizeof(struct rio_net), GFP_KERNEL);
if (net) { if (net) {
memset(net, 0, sizeof(struct rio_net));
INIT_LIST_HEAD(&net->node); INIT_LIST_HEAD(&net->node);
INIT_LIST_HEAD(&net->devices); INIT_LIST_HEAD(&net->devices);
INIT_LIST_HEAD(&net->mports); INIT_LIST_HEAD(&net->mports);

View File

@ -131,10 +131,9 @@ tape_34xx_schedule_work(struct tape_device *device, enum tape_op op)
{ {
struct tape_34xx_work *p; struct tape_34xx_work *p;
if ((p = kmalloc(sizeof(*p), GFP_ATOMIC)) == NULL) if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
return -ENOMEM; return -ENOMEM;
memset(p, 0, sizeof(*p));
INIT_WORK(&p->work, tape_34xx_work_handler); INIT_WORK(&p->work, tape_34xx_work_handler);
p->device = tape_get_device_reference(device); p->device = tape_get_device_reference(device);

View File

@ -317,8 +317,8 @@ claw_probe(struct ccwgroup_device *cgdev)
CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM); CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
return -ENOMEM; return -ENOMEM;
} }
privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL); privptr->p_mtc_envelope= kzalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL); privptr->p_env = kzalloc(sizeof(struct claw_env), GFP_KERNEL);
if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) { if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
probe_error(cgdev); probe_error(cgdev);
put_device(&cgdev->dev); put_device(&cgdev->dev);
@ -327,8 +327,6 @@ claw_probe(struct ccwgroup_device *cgdev)
CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM); CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
return -ENOMEM; return -ENOMEM;
} }
memset(privptr->p_mtc_envelope, 0x00, MAX_ENVELOPE_SIZE);
memset(privptr->p_env, 0x00, sizeof(struct claw_env));
memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8); memcpy(privptr->p_env->adapter_name,WS_NAME_NOT_DEF,8);
memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8); memcpy(privptr->p_env->host_name,WS_NAME_NOT_DEF,8);
memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8); memcpy(privptr->p_env->api_type,WS_NAME_NOT_DEF,8);
@ -3924,7 +3922,7 @@ add_channel(struct ccw_device *cdev,int i,struct claw_privbk *privptr)
snprintf(p_ch->id, CLAW_ID_SIZE, "cl-%s", cdev->dev.bus_id); snprintf(p_ch->id, CLAW_ID_SIZE, "cl-%s", cdev->dev.bus_id);
ccw_device_get_id(cdev, &dev_id); ccw_device_get_id(cdev, &dev_id);
p_ch->devno = dev_id.devno; p_ch->devno = dev_id.devno;
if ((p_ch->irb = kmalloc(sizeof (struct irb),GFP_KERNEL)) == NULL) { if ((p_ch->irb = kzalloc(sizeof (struct irb),GFP_KERNEL)) == NULL) {
printk(KERN_WARNING "%s Out of memory in %s for irb\n", printk(KERN_WARNING "%s Out of memory in %s for irb\n",
p_ch->id,__FUNCTION__); p_ch->id,__FUNCTION__);
#ifdef FUNCTRACE #ifdef FUNCTRACE
@ -3933,7 +3931,6 @@ add_channel(struct ccw_device *cdev,int i,struct claw_privbk *privptr)
#endif #endif
return -ENOMEM; return -ENOMEM;
} }
memset(p_ch->irb, 0, sizeof (struct irb));
#ifdef FUNCTRACE #ifdef FUNCTRACE
printk(KERN_INFO "%s:%s Exit on line %d\n", printk(KERN_INFO "%s:%s Exit on line %d\n",
cdev->dev.bus_id,__FUNCTION__,__LINE__); cdev->dev.bus_id,__FUNCTION__,__LINE__);

View File

@ -156,10 +156,9 @@ struct bbc_i2c_client *bbc_i2c_attach(struct linux_ebus_child *echild)
if (!bp) if (!bp)
return NULL; return NULL;
client = kmalloc(sizeof(*client), GFP_KERNEL); client = kzalloc(sizeof(*client), GFP_KERNEL);
if (!client) if (!client)
return NULL; return NULL;
memset(client, 0, sizeof(*client));
client->bp = bp; client->bp = bp;
client->echild = echild; client->echild = echild;
client->bus = echild->resource[0].start; client->bus = echild->resource[0].start;

View File

@ -656,12 +656,9 @@ static int vfc_probe(void)
if (!cards) if (!cards)
return -ENODEV; return -ENODEV;
vfc_dev_lst = kmalloc(sizeof(struct vfc_dev *) * vfc_dev_lst = kcalloc(cards + 1, sizeof(struct vfc_dev*), GFP_KERNEL);
(cards+1),
GFP_KERNEL);
if (vfc_dev_lst == NULL) if (vfc_dev_lst == NULL)
return -ENOMEM; return -ENOMEM;
memset(vfc_dev_lst, 0, sizeof(struct vfc_dev *) * (cards + 1));
vfc_dev_lst[cards] = NULL; vfc_dev_lst[cards] = NULL;
ret = register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops); ret = register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops);

View File

@ -1160,13 +1160,12 @@ static int twa_initialize_device_extension(TW_Device_Extension *tw_dev)
} }
/* Allocate event info space */ /* Allocate event info space */
tw_dev->event_queue[0] = kmalloc(sizeof(TW_Event) * TW_Q_LENGTH, GFP_KERNEL); tw_dev->event_queue[0] = kcalloc(TW_Q_LENGTH, sizeof(TW_Event), GFP_KERNEL);
if (!tw_dev->event_queue[0]) { if (!tw_dev->event_queue[0]) {
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x18, "Event info memory allocation failed"); TW_PRINTK(tw_dev->host, TW_DRIVER, 0x18, "Event info memory allocation failed");
goto out; goto out;
} }
memset(tw_dev->event_queue[0], 0, sizeof(TW_Event) * TW_Q_LENGTH);
for (i = 0; i < TW_Q_LENGTH; i++) { for (i = 0; i < TW_Q_LENGTH; i++) {
tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event))); tw_dev->event_queue[i] = (TW_Event *)((unsigned char *)tw_dev->event_queue[0] + (i * sizeof(TW_Event)));

View File

@ -3606,11 +3606,10 @@ out:
int esp_slave_alloc(struct scsi_device *SDptr) int esp_slave_alloc(struct scsi_device *SDptr)
{ {
struct esp_device *esp_dev = struct esp_device *esp_dev =
kmalloc(sizeof(struct esp_device), GFP_ATOMIC); kzalloc(sizeof(struct esp_device), GFP_ATOMIC);
if (!esp_dev) if (!esp_dev)
return -ENOMEM; return -ENOMEM;
memset(esp_dev, 0, sizeof(struct esp_device));
SDptr->hostdata = esp_dev; SDptr->hostdata = esp_dev;
return 0; return 0;
} }

View File

@ -181,13 +181,12 @@ NCR_D700_probe_one(struct NCR_D700_private *p, int siop, int irq,
struct Scsi_Host *host; struct Scsi_Host *host;
int ret; int ret;
hostdata = kmalloc(sizeof(*hostdata), GFP_KERNEL); hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
if (!hostdata) { if (!hostdata) {
printk(KERN_ERR "NCR D700: SIOP%d: Failed to allocate host" printk(KERN_ERR "NCR D700: SIOP%d: Failed to allocate host"
"data, detatching\n", siop); "data, detatching\n", siop);
return -ENOMEM; return -ENOMEM;
} }
memset(hostdata, 0, sizeof(*hostdata));
if (!request_region(region, 64, "NCR_D700")) { if (!request_region(region, 64, "NCR_D700")) {
printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n", printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n",

View File

@ -148,11 +148,10 @@ NCR_Q720_probe(struct device *dev)
__u32 base_addr, mem_size; __u32 base_addr, mem_size;
void __iomem *mem_base; void __iomem *mem_base;
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
memset(p, 0, sizeof(*p));
pos2 = mca_device_read_pos(mca_dev, 2); pos2 = mca_device_read_pos(mca_dev, 2);
/* enable device */ /* enable device */
pos2 |= NCR_Q720_POS2_BOARD_ENABLE | NCR_Q720_POS2_INTERRUPT_ENABLE; pos2 |= NCR_Q720_POS2_BOARD_ENABLE | NCR_Q720_POS2_INTERRUPT_ENABLE;

View File

@ -1159,11 +1159,10 @@ static int __imm_attach(struct parport *pb)
init_waitqueue_head(&waiting); init_waitqueue_head(&waiting);
dev = kmalloc(sizeof(imm_struct), GFP_KERNEL); dev = kzalloc(sizeof(imm_struct), GFP_KERNEL);
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
memset(dev, 0, sizeof(imm_struct));
dev->base = -1; dev->base = -1;
dev->mode = IMM_AUTODETECT; dev->mode = IMM_AUTODETECT;

View File

@ -7068,14 +7068,13 @@ ips_init_phase1(struct pci_dev *pci_dev, int *indexPtr)
subdevice_id = pci_dev->subsystem_device; subdevice_id = pci_dev->subsystem_device;
/* found a controller */ /* found a controller */
ha = kmalloc(sizeof (ips_ha_t), GFP_KERNEL); ha = kzalloc(sizeof (ips_ha_t), GFP_KERNEL);
if (ha == NULL) { if (ha == NULL) {
IPS_PRINTK(KERN_WARNING, pci_dev, IPS_PRINTK(KERN_WARNING, pci_dev,
"Unable to allocate temporary ha struct\n"); "Unable to allocate temporary ha struct\n");
return -1; return -1;
} }
memset(ha, 0, sizeof (ips_ha_t));
ips_sh[index] = NULL; ips_sh[index] = NULL;
ips_ha[index] = ha; ips_ha[index] = ha;

View File

@ -101,13 +101,12 @@ lasi700_probe(struct parisc_device *dev)
struct NCR_700_Host_Parameters *hostdata; struct NCR_700_Host_Parameters *hostdata;
struct Scsi_Host *host; struct Scsi_Host *host;
hostdata = kmalloc(sizeof(*hostdata), GFP_KERNEL); hostdata = kzalloc(sizeof(*hostdata), GFP_KERNEL);
if (!hostdata) { if (!hostdata) {
printk(KERN_ERR "%s: Failed to allocate host data\n", printk(KERN_ERR "%s: Failed to allocate host data\n",
dev->dev.bus_id); dev->dev.bus_id);
return -ENOMEM; return -ENOMEM;
} }
memset(hostdata, 0, sizeof(struct NCR_700_Host_Parameters));
hostdata->dev = &dev->dev; hostdata->dev = &dev->dev;
dma_set_mask(&dev->dev, DMA_32BIT_MASK); dma_set_mask(&dev->dev, DMA_32BIT_MASK);

View File

@ -1830,7 +1830,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
/* Initialize and populate the iocb list per host. */ /* Initialize and populate the iocb list per host. */
INIT_LIST_HEAD(&phba->lpfc_iocb_list); INIT_LIST_HEAD(&phba->lpfc_iocb_list);
for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) { for (i = 0; i < LPFC_IOCB_LIST_CNT; i++) {
iocbq_entry = kmalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL); iocbq_entry = kzalloc(sizeof(struct lpfc_iocbq), GFP_KERNEL);
if (iocbq_entry == NULL) { if (iocbq_entry == NULL) {
printk(KERN_ERR "%s: only allocated %d iocbs of " printk(KERN_ERR "%s: only allocated %d iocbs of "
"expected %d count. Unloading driver.\n", "expected %d count. Unloading driver.\n",
@ -1839,7 +1839,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
goto out_free_iocbq; goto out_free_iocbq;
} }
memset(iocbq_entry, 0, sizeof(struct lpfc_iocbq));
iotag = lpfc_sli_next_iotag(phba, iocbq_entry); iotag = lpfc_sli_next_iotag(phba, iocbq_entry);
if (iotag == 0) { if (iotag == 0) {
kfree (iocbq_entry); kfree (iocbq_entry);

View File

@ -454,7 +454,7 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
pci_set_master(pdev); pci_set_master(pdev);
// Allocate the per driver initialization structure // Allocate the per driver initialization structure
adapter = kmalloc(sizeof(adapter_t), GFP_KERNEL); adapter = kzalloc(sizeof(adapter_t), GFP_KERNEL);
if (adapter == NULL) { if (adapter == NULL) {
con_log(CL_ANN, (KERN_WARNING con_log(CL_ANN, (KERN_WARNING
@ -462,7 +462,6 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
goto out_probe_one; goto out_probe_one;
} }
memset(adapter, 0, sizeof(adapter_t));
// set up PCI related soft state and other pre-known parameters // set up PCI related soft state and other pre-known parameters
@ -746,10 +745,9 @@ megaraid_init_mbox(adapter_t *adapter)
* Allocate and initialize the init data structure for mailbox * Allocate and initialize the init data structure for mailbox
* controllers * controllers
*/ */
raid_dev = kmalloc(sizeof(mraid_device_t), GFP_KERNEL); raid_dev = kzalloc(sizeof(mraid_device_t), GFP_KERNEL);
if (raid_dev == NULL) return -1; if (raid_dev == NULL) return -1;
memset(raid_dev, 0, sizeof(mraid_device_t));
/* /*
* Attach the adapter soft state to raid device soft state * Attach the adapter soft state to raid device soft state
@ -1050,8 +1048,7 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
* since the calling routine does not yet know the number of available * since the calling routine does not yet know the number of available
* commands. * commands.
*/ */
adapter->kscb_list = kmalloc(sizeof(scb_t) * MBOX_MAX_SCSI_CMDS, adapter->kscb_list = kcalloc(MBOX_MAX_SCSI_CMDS, sizeof(scb_t), GFP_KERNEL);
GFP_KERNEL);
if (adapter->kscb_list == NULL) { if (adapter->kscb_list == NULL) {
con_log(CL_ANN, (KERN_WARNING con_log(CL_ANN, (KERN_WARNING
@ -1059,7 +1056,6 @@ megaraid_alloc_cmd_packets(adapter_t *adapter)
__LINE__)); __LINE__));
goto out_free_ibuf; goto out_free_ibuf;
} }
memset(adapter->kscb_list, 0, sizeof(scb_t) * MBOX_MAX_SCSI_CMDS);
// memory allocation for our command packets // memory allocation for our command packets
if (megaraid_mbox_setup_dma_pools(adapter) != 0) { if (megaraid_mbox_setup_dma_pools(adapter) != 0) {
@ -3495,8 +3491,7 @@ megaraid_cmm_register(adapter_t *adapter)
int i; int i;
// Allocate memory for the base list of scb for management module. // Allocate memory for the base list of scb for management module.
adapter->uscb_list = kmalloc(sizeof(scb_t) * MBOX_MAX_USER_CMDS, adapter->uscb_list = kcalloc(MBOX_MAX_USER_CMDS, sizeof(scb_t), GFP_KERNEL);
GFP_KERNEL);
if (adapter->uscb_list == NULL) { if (adapter->uscb_list == NULL) {
con_log(CL_ANN, (KERN_WARNING con_log(CL_ANN, (KERN_WARNING
@ -3504,7 +3499,6 @@ megaraid_cmm_register(adapter_t *adapter)
__LINE__)); __LINE__));
return -1; return -1;
} }
memset(adapter->uscb_list, 0, sizeof(scb_t) * MBOX_MAX_USER_CMDS);
// Initialize the synchronization parameters for resources for // Initialize the synchronization parameters for resources for

View File

@ -890,12 +890,11 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
if (lld_adp->drvr_type != DRVRTYPE_MBOX) if (lld_adp->drvr_type != DRVRTYPE_MBOX)
return (-EINVAL); return (-EINVAL);
adapter = kmalloc(sizeof(mraid_mmadp_t), GFP_KERNEL); adapter = kzalloc(sizeof(mraid_mmadp_t), GFP_KERNEL);
if (!adapter) if (!adapter)
return -ENOMEM; return -ENOMEM;
memset(adapter, 0, sizeof(mraid_mmadp_t));
adapter->unique_id = lld_adp->unique_id; adapter->unique_id = lld_adp->unique_id;
adapter->drvr_type = lld_adp->drvr_type; adapter->drvr_type = lld_adp->drvr_type;

View File

@ -1636,15 +1636,13 @@ static int megasas_alloc_cmds(struct megasas_instance *instance)
* Allocate the dynamic array first and then allocate individual * Allocate the dynamic array first and then allocate individual
* commands. * commands.
*/ */
instance->cmd_list = kmalloc(sizeof(struct megasas_cmd *) * max_cmd, instance->cmd_list = kcalloc(max_cmd, sizeof(struct megasas_cmd*), GFP_KERNEL);
GFP_KERNEL);
if (!instance->cmd_list) { if (!instance->cmd_list) {
printk(KERN_DEBUG "megasas: out of memory\n"); printk(KERN_DEBUG "megasas: out of memory\n");
return -ENOMEM; return -ENOMEM;
} }
memset(instance->cmd_list, 0, sizeof(struct megasas_cmd *) * max_cmd);
for (i = 0; i < max_cmd; i++) { for (i = 0; i < max_cmd; i++) {
instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd), instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),

Some files were not shown because too many files have changed in this diff Show More