some kmalloc/memset ->kzalloc (tree wide)
Subsystems (52)
PATCH 1/1 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)
Documentation/connector/cn_test.c | 3 +-- Documentation/filesystems/configfs/configfs_example.c | 6 ++---- arch/alpha/kernel/module.c | 3 +-- arch/arm/mach-iop13xx/pci.c | 3 +-- arch/blackfin/mm/blackfin_sram.c | 3 +-- arch/cris/arch-v32/drivers/pci/dma.c | 6 ++---- arch/powerpc/kernel/lparcfg.c | 3 +-- arch/powerpc/kernel/of_platform.c | 3 +-- block/scsi_ioctl.c | 3 +-- drivers/block/sx8.c | 3 +-- drivers/char/amiserial.c | 3 +-- drivers/char/drm/via_dmablit.c | 3 +-- drivers/char/esp.c | 6 ++---- drivers/char/hvcs.c | 4 +--- drivers/char/ipmi/ipmi_msghandler.c | 3 +-- drivers/char/pcmcia/synclink_cs.c | 3 +-- drivers/char/rio/rio_linux.c | 4 +--- drivers/char/rio/riocmd.c | 4 +--- drivers/char/rio/riotable.c | 3 +-- drivers/char/rocket.c | 3 +-- drivers/char/synclink.c | 3 +-- drivers/char/synclink_gt.c | 3 +-- drivers/char/synclinkmp.c | 3 +-- drivers/char/vt.c | 3 +-- drivers/char/watchdog/mpcore_wdt.c | 3 +-- drivers/char/watchdog/pcwd_usb.c | 3 +-- drivers/edac/edac_mc.c | 3 +-- drivers/ide/mips/swarm.c | 3 +-- drivers/infiniband/core/addr.c | 3 +-- drivers/infiniband/hw/cxgb3/iwch_cm.c | 3 +-- drivers/input/serio/ambakmi.c | 6 ++---- drivers/input/serio/pcips2.c | 6 ++---- drivers/input/serio/sa1111ps2.c | 6 ++---- drivers/macintosh/macio_asic.c | 3 +-- drivers/macintosh/smu.c | 3 +-- drivers/macintosh/therm_pm72.c | 3 +-- drivers/macintosh/therm_windtunnel.c | 3 +-- drivers/macintosh/windfarm_lm75_sensor.c | 3 +-- drivers/md/dm-raid1.c | 3 +-- drivers/media/dvb/cinergyT2/cinergyT2.c | 3 +-- drivers/media/video/cpia2/cpia2_core.c | 4 +--- drivers/media/video/msp3400-driver.c | 3 +-- drivers/media/video/planb.c | 3 +-- drivers/media/video/usbvideo/vicam.c | 3 +-- drivers/media/video/zr364xx.c | 3 +-- drivers/mfd/mcp-core.c | 3 +-- drivers/mfd/ucb1x00-core.c | 3 +-- drivers/misc/asus-laptop.c | 3 +-- drivers/misc/ibmasm/command.c | 6 ++---- drivers/misc/ibmasm/ibmasmfs.c | 3 +-- drivers/misc/ibmasm/module.c | 3 +-- drivers/mmc/card/block.c | 3 +-- drivers/mmc/core/sysfs.c | 3 +-- drivers/net/b44.c | 3 +-- drivers/net/bsd_comp.c | 3 +-- drivers/net/forcedeth.c | 6 ++---- drivers/net/hamradio/dmascc.c | 4 +--- drivers/net/irda/irport.c | 3 +-- drivers/net/irda/irtty-sir.c | 3 +-- drivers/net/iseries_veth.c | 6 ++---- drivers/net/lance.c | 3 +-- drivers/net/pcmcia/com20020_cs.c | 3 +-- drivers/net/pcmcia/ibmtr_cs.c | 3 +-- drivers/net/ppp_async.c | 3 +-- drivers/net/ppp_deflate.c | 6 ++---- drivers/net/ppp_mppe.c | 3 +-- drivers/net/ppp_synctty.c | 3 +-- drivers/net/shaper.c | 3 +-- drivers/net/wan/c101.c | 3 +-- drivers/net/wan/cosa.c | 4 +--- drivers/net/wan/cycx_main.c | 4 +--- drivers/net/wan/cycx_x25.c | 3 +-- drivers/net/wan/dscc4.c | 6 ++---- drivers/net/wan/farsync.c | 3 +-- drivers/net/wan/hostess_sv11.c | 3 +-- drivers/net/wan/n2.c | 3 +-- drivers/net/wan/pc300_drv.c | 3 +-- drivers/net/wan/pc300too.c | 3 +-- drivers/net/wan/pci200syn.c | 3 +-- drivers/net/wan/sdla.c | 3 +-- drivers/net/wan/sealevel.c | 3 +-- drivers/net/wan/wanxl.c | 3 +-- drivers/net/wan/x25_asy.c | 4 +--- drivers/nubus/nubus.c | 6 ++---- drivers/parport/parport_cs.c | 3 +-- drivers/parport/parport_serial.c | 3 +-- drivers/pci/pcie/aer/aerdrv.c | 3 +-- drivers/pnp/core.c | 3 +-- drivers/rapidio/rio-scan.c | 6 ++---- drivers/s390/char/tape_34xx.c | 3 +-- drivers/s390/net/claw.c | 9 +++------ drivers/s390/scsi/zfcp_erp.c | 3 +-- drivers/sbus/char/bbc_i2c.c | 3 +-- drivers/sbus/char/vfc_dev.c | 5 +---- drivers/scsi/3w-9xxx.c | 3 +-- drivers/scsi/NCR53C9x.c | 3 +-- drivers/scsi/NCR_D700.c | 3 +-- drivers/scsi/NCR_Q720.c | 3 +-- drivers/scsi/aacraid/aachba.c | 4 +--- drivers/scsi/imm.c | 3 +-- drivers/scsi/ips.c | 3 +-- drivers/scsi/lasi700.c | 3 +-- drivers/scsi/lpfc/lpfc_init.c | 3 +-- drivers/scsi/lpfc/lpfc_scsi.c | 3 +-- drivers/scsi/lpfc/lpfc_sli.c | 5 +---- drivers/scsi/megaraid/megaraid_mbox.c | 14 ++++---------- drivers/scsi/megaraid/megaraid_mm.c | 3 +-- drivers/scsi/megaraid/megaraid_sas.c | 4 +--- drivers/scsi/pcmcia/aha152x_stub.c | 3 +-- drivers/scsi/pcmcia/nsp_cs.c | 3 +-- drivers/scsi/pcmcia/qlogic_stub.c | 3 +-- drivers/scsi/pcmcia/sym53c500_cs.c | 3 +-- drivers/scsi/ppa.c | 3 +-- drivers/scsi/sim710.c | 3 +-- drivers/scsi/tmscsim.c | 3 +-- drivers/serial/amba-pl011.c | 3 +-- drivers/sh/superhyway/superhyway.c | 3 +-- drivers/sn/ioc3.c | 3 +-- drivers/telephony/ixj_pcmcia.c | 3 +-- drivers/usb/gadget/goku_udc.c | 3 +-- drivers/usb/gadget/serial.c | 3 +-- drivers/usb/host/ohci-hcd.c | 3 +-- drivers/usb/host/sl811_cs.c | 3 +-- drivers/usb/misc/ftdi-elan.c | 3 +-- drivers/video/amba-clcd.c | 3 +-- drivers/video/aty/atyfb_base.c | 3 +-- drivers/video/au1200fb.c | 3 +-- drivers/video/clps711xfb.c | 3 +-- drivers/video/cyber2000fb.c | 3 +-- drivers/video/offb.c | 3 +-- drivers/video/pvr2fb.c | 3 +-- drivers/video/savage/savagefb_driver.c | 3 +-- drivers/video/valkyriefb.c | 3 +-- drivers/w1/masters/matrox_w1.c | 3 +-- drivers/w1/slaves/w1_ds2433.c | 3 +-- drivers/w1/w1.c | 3 +-- drivers/w1/w1_int.c | 3 +-- fs/dlm/memory.c | 12 +++--------- fs/ext2/super.c | 4 +--- fs/partitions/check.c | 3 +-- net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 3 +-- net/mac80211/ieee80211_rate.c | 3 +-- net/mac80211/ieee80211_sta.c | 3 +-- net/netfilter/nf_conntrack_standalone.c | 3 +-- net/tipc/name_table.c | 3 +-- sound/core/seq/seq_virmidi.c | 3 +-- 146 files changed, 166 insertions(+), 352 deletions(-)
Documentation/connector/cn_test.c +1 -2
@@ -124,9 +124,8 @@ static void cn_test_timer_func(unsignedstruct cn_msg *m;char data[32 ]; - m =kmalloc (sizeof (*m) +sizeof (data),GFP_ATOMIC ); + m =kzalloc (sizeof (*m) +sizeof (data),GFP_ATOMIC );if (m) { -memset (m,0 ,sizeof (*m) +sizeof (data));memcpy (&m->id, &cn_test_id,sizeof (m->id)); m->seq = cn_test_timer_counter;
Documentation/filesystems/configfs/configfs_example.c +2 -4
@@ -277,11 +277,10 @@ static struct config_item *simple_childr {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)return NULL ; -memset (simple_child,0 ,sizeof (struct simple_child ));config_item_init_type_name (&simple_child->item, name, &simple_child_type);
@@ -364,12 +363,11 @@ static struct config_group *group_childr {struct simple_children *simple_children; - simple_children =kmalloc (sizeof (struct simple_children ), + simple_children =kzalloc (sizeof (struct simple_children ),GFP_KERNEL );if (!simple_children)return NULL ; -memset (simple_children,0 ,sizeof (struct simple_children ));config_group_init_type_name (&simple_children->group, name, &simple_children_type);
arch/alpha/kernel/module.c +1 -2
@@ -119,8 +119,7 @@ module_frob_arch_sections(Elf64_Ehdr *hd } nsyms = symtab->sh_size /sizeof (Elf64_Sym); - chains =kmalloc (nsyms *sizeof (struct got_entry ),GFP_KERNEL ); -memset (chains,0 , nsyms *sizeof (struct got_entry )); + chains =kcalloc (nsyms,sizeof (struct got_entry ),GFP_KERNEL ); got->sh_size =0 ; got->sh_addralign =8 ;
arch/arm/mach-iop13xx/pci.c +1 -2
@@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pciif (nr >1 )return 0 ; - res =kmalloc (sizeof (struct resource ) *2 ,GFP_KERNEL ); + res =kcalloc (sizeof (struct resource ),2 ,GFP_KERNEL );if (!res)panic ("PCI: unable to alloc resources" ); -memset (res,0 ,sizeof (struct resource ) *2 );/* 'nr' assumptions: * ATUX is always 0
arch/blackfin/mm/blackfin_sram.c +1 -2
@@ -521,10 +521,9 @@ void *sram_alloc_with_lsl(size_t size, ustruct sram_list_struct *lsl =NULL ;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)return NULL ; -memset (lsl,0 ,sizeof (*lsl));if (flags &L1_INST_SRAM ) addr =l1_inst_sram_alloc (size);
arch/cris/arch-v32/drivers/pci/dma.c +2 -4
@@ -91,14 +91,12 @@ int dma_declare_coherent_memory(struct dif (!mem_base) 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) goto out; -memset (dev->dma_mem,0 ,sizeof (struct dma_coherent_mem )); - dev->dma_mem->bitmap =kmalloc (bitmap_size,GFP_KERNEL ); + dev->dma_mem->bitmap =kzalloc (bitmap_size,GFP_KERNEL );if (!dev->dma_mem->bitmap) goto free1_out; -memset (dev->dma_mem->bitmap,0 , bitmap_size); dev->dma_mem->virt_base = mem_base; dev->dma_mem->device_base = device_addr;
arch/powerpc/kernel/lparcfg.c +1 -2
@@ -248,7 +248,7 @@ static void parse_system_parameter_strin }else {int splpar_strlen;int idx, w_idx; -char *workbuffer =kmalloc (SPLPAR_MAXLENGTH ,GFP_KERNEL ); +char *workbuffer =kzalloc (SPLPAR_MAXLENGTH ,GFP_KERNEL );if (!workbuffer) {printk (KERN_ERR "%s %s kmalloc failure at line %d \n" , __FILE__, __FUNCTION__, __LINE__);
@@ -261,7 +261,6 @@ #endif splpar_strlen = local_buffer[0 ] *256 + local_buffer[1 ]; local_buffer +=2 ;/* step over strlen value */ -memset (workbuffer,0 ,SPLPAR_MAXLENGTH ); w_idx =0 ; idx =0 ;while ((*local_buffer) && (idx < splpar_strlen)) {
arch/powerpc/kernel/of_platform.c +1 -2
@@ -222,10 +222,9 @@ struct of_device* of_platform_device_cre {struct of_device *dev; - dev =kmalloc (sizeof (*dev),GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return NULL ; -memset (dev,0 ,sizeof (*dev)); dev->node =of_node_get (np); dev->dma_mask =0xffffffffUL ;
block/scsi_ioctl.c +1 -2
@@ -405,11 +405,10 @@ int sg_scsi_ioctl(struct file *file, str bytes =max (in_len, out_len);if (bytes) { - buffer =kmalloc (bytes, q->bounce_gfp |GFP_USER | __GFP_NOWARN); + buffer =kzalloc (bytes, q->bounce_gfp |GFP_USER | __GFP_NOWARN);if (!buffer)return -ENOMEM ; -memset (buffer,0 , bytes); } rq =blk_get_request (q, in_len ?WRITE :READ , __GFP_WAIT);
drivers/block/sx8.c +1 -2
@@ -1608,7 +1608,7 @@ #ifdef IF_64BIT_DMA_IS_POSSIBLE /* grrrr }#endif - host =kmalloc (sizeof (*host),GFP_KERNEL ); + host =kzalloc (sizeof (*host),GFP_KERNEL );if (!host) { printk(KERN_ERR DRV_NAME "(%s): memory alloc failure\n", pci_name(pdev));
@@ -1616,7 +1616,6 @@ #endif goto err_out_regions; } -memset (host,0 ,sizeof (*host)); host->pdev = pdev; host->flags = pci_dac ?FL_DAC :0 ;spin_lock_init (&host->lock);
drivers/char/amiserial.c +1 -2
@@ -1726,12 +1726,11 @@ static int get_async_struct(int line, st *ret_info = sstate->info;return 0 ; } - info =kmalloc (sizeof (struct async_struct ),GFP_KERNEL ); + info =kzalloc (sizeof (struct async_struct ),GFP_KERNEL );if (!info) { sstate->count--;return -ENOMEM ; } -memset (info,0 ,sizeof (struct async_struct ));#ifdef DECLARE_WAITQUEUE init_waitqueue_head (&info->open_wait);init_waitqueue_head (&info->close_wait);
drivers/char/drm/via_dmablit.c +1 -2
@@ -273,10 +273,9 @@ via_alloc_desc_pages(drm_via_sg_info_t * vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page -1 ) / vsg->descriptors_per_page; -if (NULL == (vsg->desc_pages =kmalloc (sizeof (void *) * vsg->num_desc_pages,GFP_KERNEL ))) +if (NULL == (vsg->desc_pages =kcalloc (sizeof (void *), vsg->num_desc_pages,GFP_KERNEL )))return DRM_ERR (ENOMEM ); -memset (vsg->desc_pages,0 ,sizeof (void *) * vsg->num_desc_pages); vsg->state = dr_via_desc_pages_alloc; for (i=0; i<vsg->num_desc_pages; ++i) { if (NULL == (vsg->desc_pages[i] =
drivers/char/esp.c +2 -4
@@ -2466,7 +2466,7 @@ static int __init espserial_init(void)return 1 ; } - info =kmalloc (sizeof (struct esp_struct ),GFP_KERNEL ); + info =kzalloc (sizeof (struct esp_struct ),GFP_KERNEL );if (!info) {
@@ -2476,7 +2476,6 @@ static int __init espserial_init(void)return 1 ; } -memset ((void *)info,0 ,sizeof (struct esp_struct ));spin_lock_init (&info->lock);/* rx_trigger, tx_trigger are needed by autoconfig */ info->config.rx_trigger = rx_trigger;
@@ -2534,7 +2533,7 @@ static int __init espserial_init(void)if (!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) {printk (KERN_ERR "Couldn't allocate memory for esp serial device information\n" );
@@ -2543,7 +2542,6 @@ static int __init espserial_init(void)return 0 ; } -memset ((void *)info,0 ,sizeof (struct esp_struct ));/* rx_trigger, tx_trigger are needed by autoconfig */ info->config.rx_trigger = rx_trigger; info->config.tx_trigger = tx_trigger;
drivers/char/hvcs.c +1 -3
@@ -784,12 +784,10 @@ static int __devinit hvcs_probe(return -EFAULT ; } - hvcsd =kmalloc (sizeof (*hvcsd),GFP_KERNEL ); + hvcsd =kzalloc (sizeof (*hvcsd),GFP_KERNEL );if (!hvcsd)return -ENODEV ; -/* hvcsd->tty is zeroed out with the memset */ -memset (hvcsd,0x00 ,sizeof (*hvcsd));spin_lock_init (&hvcsd->lock);/* Automatically incs the refcount the first time */
drivers/char/ipmi/ipmi_msghandler.c +1 -2
@@ -2649,10 +2649,9 @@ int ipmi_register_smi(struct ipmi_smi_hareturn -ENODEV ; } - intf =kmalloc (sizeof (*intf),GFP_KERNEL ); + intf =kzalloc (sizeof (*intf),GFP_KERNEL );if (!intf)return -ENOMEM ; -memset (intf,0 ,sizeof (*intf)); intf->ipmi_version_major =ipmi_version_major (device_id); intf->ipmi_version_minor =ipmi_version_minor (device_id);
drivers/char/pcmcia/synclink_cs.c +1 -2
@@ -540,13 +540,12 @@ static int mgslpc_probe(struct pcmcia_deif (debug_level >=DEBUG_LEVEL_INFO )printk ("mgslpc_attach\n" ); - info =kmalloc (sizeof (MGSLPC_INFO ),GFP_KERNEL ); + info =kzalloc (sizeof (MGSLPC_INFO ),GFP_KERNEL );if (!info) {printk ("Error can't allocate device instance data\n" );return -ENOMEM ; } -memset (info,0 ,sizeof (MGSLPC_INFO )); info->magic =MGSLPC_MAGIC ;INIT_WORK (&info->task, bh_handler); info->max_frame_size =4096 ;
drivers/char/rio/rio_linux.c +1 -3
@@ -803,9 +803,7 @@ static void *ckmalloc(int size) {void *p; - p =kmalloc (size,GFP_KERNEL ); -if (p) -memset (p,0 , size); + p =kzalloc (size,GFP_KERNEL );return p; }
drivers/char/rio/riocmd.c +1 -3
@@ -556,9 +556,7 @@ struct CmdBlk *RIOGetCmdBlk(void) {struct CmdBlk *CmdBlkP; - CmdBlkP =kmalloc (sizeof (struct CmdBlk ),GFP_ATOMIC ); -if (CmdBlkP) -memset (CmdBlkP,0 ,sizeof (struct CmdBlk )); + CmdBlkP =kzalloc (sizeof (struct CmdBlk ),GFP_ATOMIC );return CmdBlkP; }
drivers/char/rio/riotable.c +1 -2
@@ -863,8 +863,7 @@ int RIOReMapPorts(struct rio_info *p, stif (PortP->TxRingBuffer)memset (PortP->TxRingBuffer,0 , p->RIOBufferSize);else if (p->RIOBufferSize) { - PortP->TxRingBuffer =kmalloc (p->RIOBufferSize,GFP_KERNEL ); -memset (PortP->TxRingBuffer,0 , p->RIOBufferSize); + PortP->TxRingBuffer =kzalloc (p->RIOBufferSize,GFP_KERNEL ); } PortP->TxBufferOut =0 ; PortP->TxBufferIn =0 ;
drivers/char/rocket.c +1 -2
@@ -635,12 +635,11 @@ static void init_r_port(int board, int a ctlp =sCtlNumToCtlPtr (board);/* 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) {printk (KERN_INFO "Couldn't allocate info struct for line #%d\n" , line);return ; } -memset (info,0 ,sizeof (struct r_port )); info->magic =RPORT_MAGIC ; info->line = line;
drivers/char/synclink.c +1 -2
@@ -4332,13 +4332,12 @@ static struct mgsl_struct* mgsl_allocate {struct mgsl_struct *info; - info =kmalloc (sizeof (struct mgsl_struct ), + info =kzalloc (sizeof (struct mgsl_struct ),GFP_KERNEL );if (!info) {printk ("Error can't allocate device instance data\n" ); }else { -memset (info,0 ,sizeof (struct mgsl_struct )); info->magic =MGSL_MAGIC ;INIT_WORK (&info->task, mgsl_bh_handler); info->max_frame_size =4096 ;
drivers/char/synclink_gt.c +1 -2
@@ -3422,13 +3422,12 @@ static struct slgt_info *alloc_dev(int a {struct slgt_info *info; - info =kmalloc (sizeof (struct slgt_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct slgt_info ),GFP_KERNEL );if (!info) {DBGERR (("%s device alloc failed adapter=%d port=%d\n" , driver_name, adapter_num, port_num)); }else { -memset (info,0 ,sizeof (struct slgt_info )); info->magic =MGSL_MAGIC ;INIT_WORK (&info->task, bh_handler); info->max_frame_size =4096 ;
drivers/char/synclinkmp.c +1 -2
@@ -3794,14 +3794,13 @@ static SLMP_INFO *alloc_dev(int adapter_ {SLMP_INFO *info; - info =kmalloc (sizeof (SLMP_INFO ), + info =kzalloc (sizeof (SLMP_INFO ),GFP_KERNEL );if (!info) {printk ("%s(%d) Error can't allocate device instance data for adapter %d, port %d\n" , __FILE__,__LINE__, adapter_num, port_num); }else { -memset (info,0 ,sizeof (SLMP_INFO )); info->magic =MGSL_MAGIC ;INIT_WORK (&info->task, bh_handler); info->max_frame_size =4096 ;
drivers/char/vt.c +1 -2
@@ -729,10 +729,9 @@ int vc_allocate(unsigned int currcons) //* although the numbers above are not valid since long ago, the point is still up-to-date and the comment still has its value even if only as a historical artifact. --mj, July 1998 */ - vc =kmalloc (sizeof (struct vc_data ),GFP_KERNEL ); + vc =kzalloc (sizeof (struct vc_data ),GFP_KERNEL );if (!vc)return -ENOMEM ; -memset (vc,0 ,sizeof (*vc)); vc_cons[currcons].d = vc;INIT_WORK (&vc_cons[currcons].SAK_work, vc_SAK);visual_init (vc, currcons,1 );
drivers/char/watchdog/mpcore_wdt.c +1 -2
@@ -328,12 +328,11 @@ static int __devinit mpcore_wdt_probe(st goto err_out; } - wdt =kmalloc (sizeof (struct mpcore_wdt ),GFP_KERNEL ); + wdt =kzalloc (sizeof (struct mpcore_wdt ),GFP_KERNEL );if (!wdt) { ret = -ENOMEM ; goto err_out; } -memset (wdt,0 ,sizeof (struct mpcore_wdt )); wdt->dev = &dev->dev; wdt->irq =platform_get_irq (dev,0 );
drivers/char/watchdog/pcwd_usb.c +1 -2
@@ -626,12 +626,11 @@ static int usb_pcwd_probe(struct usb_int maxp =usb_maxpacket (udev, pipe,usb_pipeout (pipe));/* 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 ) { printk(KERN_ERR PFX "Out of memory\n"); goto error; } -memset (usb_pcwd,0x00 ,sizeof (*usb_pcwd)); usb_pcwd_device = usb_pcwd;
drivers/edac/edac_mc.c +1 -2
@@ -1336,7 +1336,7 @@ struct mem_ctl_info *edac_mc_alloc(unsig pvt =align_ptr (&chi[nr_chans * nr_csrows], sz_pvt); size = ((unsigned long ) pvt) + sz_pvt; -if ((mci =kmalloc (size,GFP_KERNEL )) ==NULL ) +if ((mci =kzalloc (size,GFP_KERNEL )) ==NULL )return NULL ;/* Adjust pointers so they point within the memory we just allocated
@@ -1346,7 +1346,6 @@ struct mem_ctl_info *edac_mc_alloc(unsig chi = (struct channel_info *) (((char *) mci) + ((unsigned long ) chi)); pvt = sz_pvt ? (((char *) mci) + ((unsigned long ) pvt)) :NULL ; -memset (mci,0 , size);/* clear all fields */ mci->csrows = csi; mci->pvt_info = pvt; mci->nr_csrows = nr_csrows;
drivers/ide/mips/swarm.c +1 -2
@@ -165,12 +165,11 @@ static int __devinit swarm_ide_init_modu goto out; } -if (!(pldev =kmalloc (sizeof (*pldev),GFP_KERNEL ))) { +if (!(pldev =kzalloc (sizeof (*pldev),GFP_KERNEL ))) { err = -ENOMEM ; goto out_unregister_driver; } -memset (pldev,0 ,sizeof (*pldev)); pldev->name = swarm_ide_string; pldev->id =0 ; pldev->dev.release = swarm_ide_platform_release;
drivers/infiniband/core/addr.c +1 -2
@@ -295,10 +295,9 @@ int rdma_resolve_ip(struct rdma_addr_clistruct addr_req *req;int ret =0 ; - req =kmalloc (sizeof *req,GFP_KERNEL ); + req =kzalloc (sizeof *req,GFP_KERNEL );if (!req)return -ENOMEM ; -memset (req,0 ,sizeof *req);if (src_addr)memcpy (&req->src_addr, src_addr,ip_addr_size (src_addr));
drivers/infiniband/hw/cxgb3/iwch_cm.c +1 -2
@@ -229,9 +229,8 @@ static void *alloc_ep(int size, gfp_t gf {struct iwch_ep_common *epc; - epc =kmalloc (size, gfp); + epc =kzalloc (size, gfp);if (epc) { -memset (epc,0 , size);kref_init (&epc->kref);spin_lock_init (&epc->lock);init_waitqueue_head (&epc->waitq);
drivers/input/serio/ambakmi.c +2 -4
@@ -117,15 +117,13 @@ static int amba_kmi_probe(struct amba_deif (ret)return ret; - kmi =kmalloc (sizeof (struct amba_kmi_port ),GFP_KERNEL ); - io =kmalloc (sizeof (struct serio ),GFP_KERNEL ); + kmi =kzalloc (sizeof (struct amba_kmi_port ),GFP_KERNEL ); + io =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (!kmi || !io) { ret = -ENOMEM ; goto out; } -memset (kmi,0 ,sizeof (struct amba_kmi_port )); -memset (io,0 ,sizeof (struct serio )); io->id.type =SERIO_8042 ; io->write = amba_kmi_write;
drivers/input/serio/pcips2.c +2 -4
@@ -140,15 +140,13 @@ static int __devinit pcips2_probe(structif (ret) goto disable; - ps2if =kmalloc (sizeof (struct pcips2_data ),GFP_KERNEL ); - serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); + ps2if =kzalloc (sizeof (struct pcips2_data ),GFP_KERNEL ); + serio =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (!ps2if || !serio) { ret = -ENOMEM ; goto release; } -memset (ps2if,0 ,sizeof (struct pcips2_data )); -memset (serio,0 ,sizeof (struct serio )); serio->id.type =SERIO_8042 ; serio->write = pcips2_write;
drivers/input/serio/sa1111ps2.c +2 -4
@@ -234,15 +234,13 @@ static int __devinit ps2_probe(struct sastruct serio *serio;int ret; - ps2if =kmalloc (sizeof (struct ps2if ),GFP_KERNEL ); - serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); + ps2if =kzalloc (sizeof (struct ps2if ),GFP_KERNEL ); + serio =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (!ps2if || !serio) { ret = -ENOMEM ; goto free; } -memset (ps2if,0 ,sizeof (struct ps2if )); -memset (serio,0 ,sizeof (struct serio )); serio->id.type =SERIO_8042 ; serio->write = ps2_write;
drivers/macintosh/macio_asic.c +1 -2
@@ -365,10 +365,9 @@ static struct macio_dev * macio_add_one_if (np ==NULL )return NULL ; - dev =kmalloc (sizeof (*dev),GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return NULL ; -memset (dev,0 ,sizeof (*dev)); dev->bus = &chip->lbus; dev->media_bay = in_bay;
drivers/macintosh/smu.c +1 -2
@@ -1053,10 +1053,9 @@ static int smu_open(struct inode *inode,struct smu_private *pp;unsigned long flags; - pp =kmalloc (sizeof (struct smu_private ),GFP_KERNEL ); + pp =kzalloc (sizeof (struct smu_private ),GFP_KERNEL );if (pp ==0 )return -ENOMEM ; -memset (pp,0 ,sizeof (struct smu_private ));spin_lock_init (&pp->lock); pp->mode = smu_file_commands;init_waitqueue_head (&pp->wait);
drivers/macintosh/therm_pm72.c +1 -2
@@ -318,10 +318,9 @@ static struct i2c_client *attach_i2c_chiif (adap ==NULL )return NULL ; - clt =kmalloc (sizeof (struct i2c_client ),GFP_KERNEL ); + clt =kzalloc (sizeof (struct i2c_client ),GFP_KERNEL );if (clt ==NULL )return NULL ; -memset (clt,0 ,sizeof (struct i2c_client )); clt->addr = (id >>1 ) &0x7f ; clt->adapter = adap;
drivers/macintosh/therm_windtunnel.c +1 -2
@@ -431,9 +431,8 @@ do_probe( struct i2c_adapter *adapter, i | I2C_FUNC_SMBUS_WRITE_BYTE) )return 0 ; -if ( !(cl=kmalloc (sizeof (*cl),GFP_KERNEL )) ) +if ( !(cl=kzalloc (sizeof (*cl),GFP_KERNEL )) )return -ENOMEM ; -memset ( cl,0 ,sizeof (struct i2c_client ) ); cl->addr = addr; cl->adapter = adapter;
drivers/macintosh/windfarm_lm75_sensor.c +1 -2
@@ -117,10 +117,9 @@ static struct wf_lm75_sensor *wf_lm75_crDBG ("wf_lm75: creating %s device at address 0x%02x\n" , 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 )return NULL ; -memset (lm,0 ,sizeof (struct wf_lm75_sensor ));/* Usual rant about sensor names not beeing very consistent in * the device-tree, oh well ...
drivers/md/dm-raid1.c +1 -2
@@ -918,13 +918,12 @@ static struct mirror_set *alloc_context( len =sizeof (*ms) + (sizeof (ms->mirror[0 ]) * nr_mirrors); - ms =kmalloc (len,GFP_KERNEL ); + ms =kzalloc (len,GFP_KERNEL );if (!ms) { ti->error ="Cannot allocate mirror context" ;return NULL ; } -memset (ms,0 , len);spin_lock_init (&ms->lock); ms->ti = ti;
drivers/media/dvb/cinergyT2/cinergyT2.c +1 -2
@@ -905,12 +905,11 @@ static int cinergyt2_probe (struct usb_istruct cinergyt2 *cinergyt2;int err; -if (!(cinergyt2 =kmalloc (sizeof (struct cinergyt2 ),GFP_KERNEL ))) { +if (!(cinergyt2 =kzalloc (sizeof (struct cinergyt2 ),GFP_KERNEL ))) {dprintk (1 ,"out of memory?!?\n" );return -ENOMEM ; } -memset (cinergyt2,0 ,sizeof (struct cinergyt2 ));usb_set_intfdata (intf, (void *) cinergyt2);mutex_init (&cinergyt2->sem);
drivers/media/video/cpia2/cpia2_core.c +1 -3
@@ -2227,15 +2227,13 @@ struct camera_data *cpia2_init_camera_st {struct camera_data *cam; - cam =kmalloc (sizeof (*cam),GFP_KERNEL ); + cam =kzalloc (sizeof (*cam),GFP_KERNEL );if (!cam) {ERR ("couldn't kmalloc cpia2 struct\n" );return NULL ; } -/* Default everything to 0 */ -memset (cam,0 ,sizeof (struct camera_data )); cam->present =1 ;mutex_init (&cam->busy_lock);
drivers/media/video/msp3400-driver.c +1 -2
@@ -814,10 +814,9 @@ static int msp_attach(struct i2c_adapterint msp_product, msp_prod_hi, msp_prod_lo;int msp_rom; - client =kmalloc (sizeof (*client),GFP_KERNEL ); + client =kzalloc (sizeof (*client),GFP_KERNEL );if (client ==NULL )return -ENOMEM ; -memset (client,0 ,sizeof (*client)); client->addr = address; client->adapter = adapter; client->driver = &i2c_driver;
drivers/media/video/planb.c +1 -2
@@ -353,9 +353,8 @@ static int planb_prepare_open(struct pla * PLANB_DUMMY)*sizeof(struct dbdma_cmd) +(PLANB_MAXLINES *((PLANB_MAXPIXELS +7 )& ~7 ))/8 +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 ; -memset ((void *) pb->priv_space,0 , size); pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *)DBDMA_ALIGN (pb->priv_space); pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size;
drivers/media/video/usbvideo/vicam.c +1 -2
@@ -1305,13 +1305,12 @@ vicam_probe( struct usb_interface *intf, }if ((cam = -kmalloc (sizeof (struct vicam_camera ),GFP_KERNEL )) ==NULL ) { +kzalloc (sizeof (struct vicam_camera ),GFP_KERNEL )) ==NULL ) {printk (KERN_WARNING "could not allocate kernel memory for vicam_camera struct\n" );return -ENOMEM ; } -memset (cam,0 ,sizeof (struct vicam_camera )); cam->shutter_speed =15 ;
drivers/media/video/zr364xx.c +1 -2
@@ -800,11 +800,10 @@ static int zr364xx_probe(struct usb_inte udev->descriptor.idProduct);if ((cam = -kmalloc (sizeof (struct zr364xx_camera ),GFP_KERNEL )) ==NULL ) { +kzalloc (sizeof (struct zr364xx_camera ),GFP_KERNEL )) ==NULL ) {info ("cam: out of memory !" );return -ENODEV ; } -memset (cam,0x00 ,sizeof (struct zr364xx_camera ));/* save the init method used by this camera */ cam->method = id->driver_info;
drivers/mfd/mcp-core.c +1 -2
@@ -200,9 +200,8 @@ struct mcp *mcp_host_alloc(struct device {struct mcp *mcp; - mcp =kmalloc (sizeof (struct mcp ) + size,GFP_KERNEL ); + mcp =kzalloc (sizeof (struct mcp ) + size,GFP_KERNEL );if (mcp) { -memset (mcp,0 ,sizeof (struct mcp ) + size);spin_lock_init (&mcp->lock); mcp->attached_device.parent = parent; mcp->attached_device.bus = &mcp_bus_type;
drivers/mfd/ucb1x00-core.c +1 -2
@@ -484,12 +484,11 @@ static int ucb1x00_probe(struct mcp *mcp goto err_disable; } - ucb =kmalloc (sizeof (struct ucb1x00 ),GFP_KERNEL ); + ucb =kzalloc (sizeof (struct ucb1x00 ),GFP_KERNEL ); ret = -ENOMEM ;if (!ucb) goto err_disable; -memset (ucb,0 ,sizeof (struct ucb1x00 )); ucb->cdev.class = &ucb1x00_class; ucb->cdev.dev = &mcp->attached_device;
drivers/misc/asus-laptop.c +1 -2
@@ -980,10 +980,9 @@ static int asus_hotk_add(struct acpi_devprintk (ASUS_NOTICE "Asus Laptop Support version %s\n" ,ASUS_LAPTOP_VERSION ); - hotk =kmalloc (sizeof (struct asus_hotk ),GFP_KERNEL ); + hotk =kzalloc (sizeof (struct asus_hotk ),GFP_KERNEL );if (!hotk)return -ENOMEM ; -memset (hotk,0 ,sizeof (struct asus_hotk )); hotk->handle = device->handle;strcpy (acpi_device_name (device),ASUS_HOTK_DEVICE_NAME );
drivers/misc/ibmasm/command.c +2 -4
@@ -41,18 +41,16 @@ struct command *ibmasm_new_command(strucif (buffer_size >IBMASM_CMD_MAX_BUFFER_SIZE )return NULL ; - cmd =kmalloc (sizeof (struct command ),GFP_KERNEL ); + cmd =kzalloc (sizeof (struct command ),GFP_KERNEL );if (cmd ==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 ) {kfree (cmd);return NULL ; } -memset (cmd->buffer,0 , buffer_size); cmd->buffer_size = buffer_size;kobject_init (&cmd->kobj);
drivers/misc/ibmasm/ibmasmfs.c +1 -2
@@ -563,11 +563,10 @@ static ssize_t remote_settings_file_writif (*offset !=0 )return 0 ; - buff =kmalloc (count +1 ,GFP_KERNEL ); + buff =kzalloc (count +1 ,GFP_KERNEL );if (!buff)return -ENOMEM ; -memset (buff,0x0 , count +1 );if (copy_from_user (buff, ubuff, count)) {kfree (buff);
drivers/misc/ibmasm/module.c +1 -2
@@ -77,13 +77,12 @@ static int __devinit ibmasm_init_one(str/* vnc client won't work without bus-mastering */ pci_set_master (pdev); - sp =kmalloc (sizeof (struct service_processor ),GFP_KERNEL ); + sp =kzalloc (sizeof (struct service_processor ),GFP_KERNEL );if (sp ==NULL ) {dev_err (&pdev->dev,"Failed to allocate memory\n" ); result = -ENOMEM ; goto error_kmalloc; } -memset (sp,0 ,sizeof (struct service_processor ));spin_lock_init (&sp->lock);INIT_LIST_HEAD (&sp->command_queue);
drivers/mmc/card/block.c +1 -2
@@ -409,13 +409,12 @@ static struct mmc_blk_data *mmc_blk_alloreturn ERR_PTR (-ENOSPC );__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) { ret = -ENOMEM ; goto out; } -memset (md,0 ,sizeof (struct mmc_blk_data ));/* * Set the read-only status based on the supported commands
drivers/mmc/core/sysfs.c +1 -2
@@ -259,9 +259,8 @@ struct mmc_host *mmc_alloc_host_sysfs(in {struct mmc_host *host; - host =kmalloc (sizeof (struct mmc_host ) + extra,GFP_KERNEL ); + host =kzalloc (sizeof (struct mmc_host ) + extra,GFP_KERNEL );if (host) { -memset (host,0 ,sizeof (struct mmc_host ) + extra); host->parent = dev; host->class_dev.parent = dev;
drivers/net/b44.c +1 -2
@@ -1522,14 +1522,13 @@ static void b44_setup_pseudo_magicp(struu8 *pwol_pattern;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) { printk(KERN_ERR PFX "Memory not available for WOL\n");return ; }/* Ipv4 magic packet pattern - pattern 0.*/ -memset (pwol_pattern,0 ,B44_PATTERN_SIZE );memset (pwol_mask,0 ,B44_PMASK_SIZE ); plen0 =b44_magic_pattern (bp->dev->dev_addr, pwol_pattern, pwol_mask,B44_ETHIPV4UDP_HLEN );
drivers/net/bsd_comp.c +1 -2
@@ -395,14 +395,13 @@ static void *bsd_alloc (unsigned char *o* Allocate the main control structure for this instance. */ maxmaxcode =MAXCODE (bits); - db =kmalloc (sizeof (struct bsd_db ), + db =kzalloc (sizeof (struct bsd_db ),GFP_KERNEL );if (!db) {return NULL ; } -memset (db,0 ,sizeof (struct bsd_db ));/* * Allocate space for the dictionary. This may be more than one page in * length.
drivers/net/forcedeth.c +2 -4
@@ -4995,12 +4995,10 @@ static int __devinit nv_probe(struct pci goto out_unmap; 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->tx_skb =kmalloc (sizeof (struct nv_skb_map ) * np->tx_ring_size,GFP_KERNEL ); + np->rx_skb =kcalloc (sizeof (struct nv_skb_map ), np->rx_ring_size,GFP_KERNEL ); + np->tx_skb =kcalloc (sizeof (struct nv_skb_map ), np->tx_ring_size,GFP_KERNEL );if (!np->rx_skb || !np->tx_skb) 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->stop = nv_close;
drivers/net/hamradio/dmascc.c +1 -3
@@ -454,7 +454,7 @@ static int __init setup_adapter(int cardchar *chipnames[] =CHIPNAMES ;/* Allocate memory */ - info =kmalloc (sizeof (struct scc_info ),GFP_KERNEL |GFP_DMA ); + info =kzalloc (sizeof (struct scc_info ),GFP_KERNEL |GFP_DMA );if (!info) { printk(KERN_ERR "dmascc: " "could not allocate memory for %s at %#3x\n",
@@ -462,8 +462,6 @@ static int __init setup_adapter(int card 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);if (!info->dev[0 ]) {
drivers/net/irda/irport.c +1 -2
@@ -164,14 +164,13 @@ irport_open(int i, unsigned int iobase,/* Allocate memory if needed */ 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 );if (self->tx_buff.head ==NULL ) {IRDA_ERROR ("%s(), can't allocate memory for " "transmit buffer!\n" , __FUNCTION__); goto err_out4; } -memset (self->tx_buff.head,0 , self->tx_buff.truesize); } self->tx_buff.data = self->tx_buff.head;
drivers/net/irda/irtty-sir.c +1 -2
@@ -505,10 +505,9 @@ static int irtty_open(struct tty_struct }/* allocate private device info block */ - priv =kmalloc (sizeof (*priv),GFP_KERNEL ); + priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv) goto out_put; -memset (priv,0 ,sizeof (*priv)); priv->magic =IRTTY_MAGIC ; priv->tty = tty;
drivers/net/iseries_veth.c +2 -4
@@ -822,10 +822,9 @@ static int veth_init_connection(u8 rlp) || ! HvLpConfig_doLpsCommunicateOnVirtualLan(this_lp, rlp) )return 0 ; - cnx =kmalloc (sizeof (*cnx),GFP_KERNEL ); + cnx =kzalloc (sizeof (*cnx),GFP_KERNEL );if (! cnx)return -ENOMEM ; -memset (cnx,0 ,sizeof (*cnx)); cnx->remote_lp = rlp;spin_lock_init (&cnx->lock);
@@ -852,14 +851,13 @@ static int veth_init_connection(u8 rlp)if (rc !=0 )return rc; - msgs =kmalloc (VETH_NUMBUFFERS *sizeof (struct veth_msg ),GFP_KERNEL ); + msgs =kcalloc (VETH_NUMBUFFERS ,sizeof (struct veth_msg ),GFP_KERNEL );if (! msgs) {veth_error ("Can't allocate buffers for LPAR %d.\n" , rlp);return -ENOMEM ; } cnx->msgs = msgs; -memset (msgs,0 ,VETH_NUMBUFFERS *sizeof (struct veth_msg ));for (i =0 ; i <VETH_NUMBUFFERS ; i++) { msgs[i].token = i;
drivers/net/lance.c +1 -2
@@ -533,11 +533,10 @@ static int __init lance_probe1(struct ne dev->base_addr = ioaddr;/* 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 )return -ENODEV ;if (lance_debug >6 )printk (" (#0x%05lx)" , (unsigned long )lp); -memset (lp,0 ,sizeof (*lp)); dev->priv = lp; lp->name = chipname; lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE,
drivers/net/pcmcia/com20020_cs.c +1 -2
@@ -147,7 +147,7 @@ static int com20020_probe(struct pcmcia_DEBUG (0 ,"com20020_attach()\n" );/* Create new network device */ - info =kmalloc (sizeof (struct com20020_dev_t ),GFP_KERNEL ); + info =kzalloc (sizeof (struct com20020_dev_t ),GFP_KERNEL );if (!info) goto fail_alloc_info;
@@ -155,7 +155,6 @@ static int com20020_probe(struct pcmcia_if (!dev) goto fail_alloc_dev; -memset (info,0 ,sizeof (struct com20020_dev_t )); lp = dev->priv; lp->timeout = timeout; lp->backplane = backplane;
drivers/net/pcmcia/ibmtr_cs.c +1 -2
@@ -146,9 +146,8 @@ static int __devinit ibmtr_attach(structDEBUG (0 ,"ibmtr_attach()\n" );/* Create new token-ring device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (*info)); dev =alloc_trdev (sizeof (struct tok_info ));if (!dev) {kfree (info);
drivers/net/ppp_async.c +1 -2
@@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *ttyint err; err = -ENOMEM ; - ap =kmalloc (sizeof (*ap),GFP_KERNEL ); + ap =kzalloc (sizeof (*ap),GFP_KERNEL );if (ap ==0 ) goto out;/* initialize the asyncppp structure */ -memset (ap,0 ,sizeof (*ap)); ap->tty = tty; ap->mru =PPP_MRU ;spin_lock_init (&ap->xmit_lock);
drivers/net/ppp_deflate.c +2 -4
@@ -121,12 +121,11 @@ static void *z_comp_alloc(unsigned charif (w_size <DEFLATE_MIN_SIZE || w_size >DEFLATE_MAX_SIZE )return NULL ; - state =kmalloc (sizeof (*state), + state =kzalloc (sizeof (*state),GFP_KERNEL );if (state ==NULL )return NULL ; -memset (state,0 ,sizeof (struct ppp_deflate_state )); state->strm.next_in =NULL ; state->w_size = w_size; state->strm.workspace =vmalloc (zlib_deflate_workspacesize ());
@@ -341,11 +340,10 @@ static void *z_decomp_alloc(unsigned chaif (w_size <DEFLATE_MIN_SIZE || w_size >DEFLATE_MAX_SIZE )return NULL ; - state =kmalloc (sizeof (*state),GFP_KERNEL ); + state =kzalloc (sizeof (*state),GFP_KERNEL );if (state ==NULL )return NULL ; -memset (state,0 ,sizeof (struct ppp_deflate_state )); state->w_size = w_size; state->strm.next_out =NULL ; state->strm.workspace = kmalloc(zlib_inflate_workspacesize(),
drivers/net/ppp_mppe.c +1 -2
@@ -200,11 +200,10 @@ static void *mppe_alloc(unsigned char *o || options[0] != CI_MPPE || options[1] != CILEN_MPPE) goto out; - state =kmalloc (sizeof (*state),GFP_KERNEL ); + state =kzalloc (sizeof (*state),GFP_KERNEL );if (state ==NULL ) goto out; -memset (state,0 ,sizeof (*state)); state->arc4 =crypto_alloc_blkcipher ("ecb(arc4)" ,0 ,CRYPTO_ALG_ASYNC );if (IS_ERR (state->arc4)) {
drivers/net/ppp_synctty.c +1 -2
@@ -207,13 +207,12 @@ ppp_sync_open(struct tty_struct *tty)struct syncppp *ap;int err; - ap =kmalloc (sizeof (*ap),GFP_KERNEL ); + ap =kzalloc (sizeof (*ap),GFP_KERNEL ); err = -ENOMEM ;if (ap ==0 ) goto out;/* initialize the syncppp structure */ -memset (ap,0 ,sizeof (*ap)); ap->tty = tty; ap->mru =PPP_MRU ;spin_lock_init (&ap->xmit_lock);
drivers/net/shaper.c +1 -2
@@ -600,10 +600,9 @@ static int __init shaper_init(void)return -ENODEV ; alloc_size =sizeof (*dev) * shapers; - devs =kmalloc (alloc_size,GFP_KERNEL ); + devs =kzalloc (alloc_size,GFP_KERNEL );if (!devs)return -ENOMEM ; -memset (devs,0 , alloc_size);for (i =0 ; i < shapers; i++) {
drivers/net/wan/c101.c +1 -2
@@ -315,12 +315,11 @@ static int __init c101_run(unsigned longreturn -ENODEV ; } - card =kmalloc (sizeof (card_t),GFP_KERNEL ); + card =kzalloc (sizeof (card_t),GFP_KERNEL );if (card ==NULL ) {printk (KERN_ERR "c101: unable to allocate memory\n" );return -ENOBUFS ; } -memset (card,0 ,sizeof (card_t)); card->dev =alloc_hdlcdev (card);if (!card->dev) {
drivers/net/wan/cosa.c +1 -3
@@ -572,13 +572,11 @@ #endifsprintf (cosa->name,"cosa%d" , cosa->num);/* Initialize the per-channel data */ - cosa->chan =kmalloc (sizeof (struct channel_data )*cosa->nchannels, -GFP_KERNEL ); + cosa->chan =kcalloc (sizeof (struct channel_data ), cosa->nchannels,GFP_KERNEL );if (!cosa->chan) { err = -ENOMEM ; goto err_out3; } -memset (cosa->chan,0 ,sizeof (struct channel_data )*cosa->nchannels);for (i=0 ; i<cosa->nchannels; i++) { cosa->chan[i].cosa = cosa; cosa->chan[i].num = i;
drivers/net/wan/cycx_main.c +1 -3
@@ -113,12 +113,10 @@ static int __init cycx_init(void)/* Verify number of cards and allocate adapter data space */ cycx_ncards =min_t (int, cycx_ncards,CYCX_MAX_CARDS ); cycx_ncards =max_t (int, cycx_ncards,1 ); - cycx_card_array =kmalloc (sizeof (struct cycx_device ) * cycx_ncards, -GFP_KERNEL ); + cycx_card_array =kcalloc (sizeof (struct cycx_device ), cycx_ncards,GFP_KERNEL );if (!cycx_card_array) goto out; -memset (cycx_card_array,0 ,sizeof (struct cycx_device ) * cycx_ncards);/* Register adapters with WAN router */ for (cnt =0 ; cnt < cycx_ncards; ++cnt) {
drivers/net/wan/cycx_x25.c +1 -2
@@ -376,11 +376,10 @@ static int cycx_wan_new_if(struct wan_de }/* 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)return -ENOMEM ; -memset (chan,0 ,sizeof (*chan));strcpy (chan->name, conf->name); chan->card = card; chan->link = conf->port;
drivers/net/wan/dscc4.c +2 -4
@@ -890,12 +890,11 @@ static int dscc4_found1(struct pci_dev *struct dscc4_dev_priv *root;int i, ret = -ENOMEM ; - root =kmalloc (dev_per_card*sizeof (*root),GFP_KERNEL ); + root =kcalloc (dev_per_card,sizeof (*root),GFP_KERNEL );if (!root) {printk (KERN_ERR "%s: can't allocate data\n" ,DRV_NAME ); goto err_out; } -memset (root,0 , dev_per_card*sizeof (*root));for (i =0 ; i < dev_per_card; i++) { root[i].dev =alloc_hdlcdev (root + i);
@@ -903,12 +902,11 @@ static int dscc4_found1(struct pci_dev * goto err_free_dev; } - ppriv =kmalloc (sizeof (*ppriv),GFP_KERNEL ); + ppriv =kzalloc (sizeof (*ppriv),GFP_KERNEL );if (!ppriv) {printk (KERN_ERR "%s: can't allocate private data\n" ,DRV_NAME ); goto err_free_dev; } -memset (ppriv,0 ,sizeof (struct dscc4_pci_priv )); ppriv->root = root;spin_lock_init (&ppriv->lock);
drivers/net/wan/farsync.c +1 -2
@@ -2476,13 +2476,12 @@ fst_add_one(struct pci_dev *pdev, const }/* 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 ) {printk_err ("FarSync card found but insufficient memory for" " driver storage\n" );return -ENOMEM ; } -memset (card,0 ,sizeof (struct fst_card_info ));/* Try to enable the device */ if ((err =pci_enable_device (pdev)) !=0 ) {
drivers/net/wan/hostess_sv11.c +1 -2
@@ -231,11 +231,10 @@ static struct sv11_device *sv11_init(intreturn NULL ; } - sv =kmalloc (sizeof (struct sv11_device ),GFP_KERNEL ); + sv =kzalloc (sizeof (struct sv11_device ),GFP_KERNEL );if (!sv) goto fail3; -memset (sv,0 ,sizeof (*sv)); sv->if_ptr=&sv->netdev; sv->netdev.dev =alloc_netdev (0 ,"hdlc%d" , sv11_setup);
drivers/net/wan/n2.c +1 -2
@@ -351,12 +351,11 @@ static int __init n2_run(unsigned long ireturn -ENODEV ; } - card =kmalloc (sizeof (card_t),GFP_KERNEL ); + card =kzalloc (sizeof (card_t),GFP_KERNEL );if (card ==NULL ) {printk (KERN_ERR "n2: unable to allocate memory\n" );return -ENOBUFS ; } -memset (card,0 ,sizeof (card_t)); card->ports[0 ].dev =alloc_hdlcdev (&card->ports[0 ]); card->ports[1 ].dev =alloc_hdlcdev (&card->ports[1 ]);
drivers/net/wan/pc300_drv.c +1 -2
@@ -3455,7 +3455,7 @@ #endifif ((err =pci_enable_device (pdev)) <0 )return err; - card =kmalloc (sizeof (pc300_t),GFP_KERNEL ); + card =kzalloc (sizeof (pc300_t),GFP_KERNEL );if (card ==NULL ) { printk("PC300 found at RAM 0x%016llx, " "but could not allocate card structure.\n",
@@ -3463,7 +3463,6 @@ #endif err = -ENOMEM ; goto err_disable_dev; } -memset (card,0 ,sizeof (pc300_t)); err = -ENODEV ;
drivers/net/wan/pc300too.c +1 -2
@@ -335,14 +335,13 @@ #endifreturn i; } - card =kmalloc (sizeof (card_t),GFP_KERNEL ); + card =kzalloc (sizeof (card_t),GFP_KERNEL );if (card ==NULL ) {printk (KERN_ERR "pc300: unable to allocate memory\n" );pci_release_regions (pdev);pci_disable_device (pdev);return -ENOBUFS ; } -memset (card,0 ,sizeof (card_t));pci_set_drvdata (pdev, card); if (pdev->device == PCI_DEVICE_ID_PC300_TE_1 ||
drivers/net/wan/pci200syn.c +1 -2
@@ -313,14 +313,13 @@ #endifreturn i; } - card =kmalloc (sizeof (card_t),GFP_KERNEL ); + card =kzalloc (sizeof (card_t),GFP_KERNEL );if (card ==NULL ) {printk (KERN_ERR "pci200syn: unable to allocate memory\n" );pci_release_regions (pdev);pci_disable_device (pdev);return -ENOBUFS ; } -memset (card,0 ,sizeof (card_t));pci_set_drvdata (pdev, card); card->ports[0 ].dev =alloc_hdlcdev (&card->ports[0 ]); card->ports[1 ].dev =alloc_hdlcdev (&card->ports[1 ]);
drivers/net/wan/sdla.c +1 -2
@@ -1196,10 +1196,9 @@ static int sdla_xfer(struct net_device *if (read) { - temp =kmalloc (mem.len,GFP_KERNEL ); + temp =kzalloc (mem.len,GFP_KERNEL );if (!temp)return (-ENOMEM ); -memset (temp,0 , mem.len);sdla_read (dev, mem.addr, temp, mem.len);if (copy_to_user (mem.data, temp, mem.len)) {
drivers/net/wan/sealevel.c +1 -2
@@ -270,11 +270,10 @@ static __init struct slvl_board *slvl_inreturn NULL ; } - b =kmalloc (sizeof (struct slvl_board ),GFP_KERNEL ); + b =kzalloc (sizeof (struct slvl_board ),GFP_KERNEL );if (!b) goto fail3; -memset (b,0 ,sizeof (*b));if (!(b->dev[0 ]=slvl_alloc (iobase, irq))) goto fail2;
drivers/net/wan/wanxl.c +1 -2
@@ -599,7 +599,7 @@ #endif } alloc_size =sizeof (card_t) + ports *sizeof (port_t); - card =kmalloc (alloc_size,GFP_KERNEL ); + card =kzalloc (alloc_size,GFP_KERNEL );if (card ==NULL ) {printk (KERN_ERR "wanXL %s: unable to allocate memory\n" ,pci_name (pdev));
@@ -607,7 +607,6 @@ #endifpci_disable_device (pdev);return -ENOBUFS ; } -memset (card,0 , alloc_size);pci_set_drvdata (pdev, card); card->pdev = pdev;
drivers/net/wan/x25_asy.c +1 -3
@@ -786,14 +786,12 @@ static int __init init_x25_asy(void)printk (KERN_INFO "X.25 async: version 0.00 ALPHA " "(dynamic channels, max=%d).\n" , x25_asy_maxdev ); - x25_asy_devs =kmalloc (sizeof (struct net_device *)*x25_asy_maxdev, -GFP_KERNEL ); + x25_asy_devs =kcalloc (sizeof (struct net_device *), x25_asy_maxdev,GFP_KERNEL );if (!x25_asy_devs) {printk (KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " "array! Uaargh! (-> No X.25 available)\n" );return -ENOMEM ; } -memset (x25_asy_devs,0 ,sizeof (struct net_device *)*x25_asy_maxdev);return tty_register_ldisc (N_X25 , &x25_ldisc); }
drivers/nubus/nubus.c +2 -4
@@ -466,9 +466,8 @@ static struct nubus_dev* __init parent->base, dir.base);/* 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 ; -memset (dev,0 ,sizeof (*dev)); dev->resid = parent->type; dev->directory = dir.base; dev->board = board;
@@ -800,9 +799,8 @@ static struct nubus_board* __init nubus_nubus_rewind (&rp,FORMAT_BLOCK_SIZE , bytelanes);/* 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 ; -memset (board,0 ,sizeof (*board)); board->fblock = rp;/* Dump the format block for debugging purposes */
drivers/parport/parport_cs.c +1 -2
@@ -105,9 +105,8 @@ static int parport_probe(struct pcmcia_dDEBUG (0 ,"parport_attach()\n" );/* Create new parport device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (*info)); link->priv = info; info->p_dev = link;
drivers/parport/parport_serial.c +1 -2
@@ -324,10 +324,9 @@ static int __devinit parport_serial_pci_struct parport_serial_private *priv;int err; - priv =kmalloc (sizeof *priv,GFP_KERNEL ); + priv =kzalloc (sizeof *priv,GFP_KERNEL );if (!priv)return -ENOMEM ; -memset (priv,0 ,sizeof (struct parport_serial_private ));pci_set_drvdata (dev, priv); err =pci_enable_device (dev);
drivers/pci/pcie/aer/aerdrv.c +1 -2
@@ -148,11 +148,10 @@ static struct aer_rpc* aer_alloc_rpc(str {struct aer_rpc *rpc; -if (!(rpc =kmalloc (sizeof (struct aer_rpc ), +if (!(rpc =kzalloc (sizeof (struct aer_rpc ),GFP_KERNEL )))return NULL ; -memset (rpc,0 ,sizeof (struct aer_rpc ));/* * Initialize Root lock access, e_lock, to Root Error Status Reg, * Root Error ID Reg, and Root error producer/consumer index.
drivers/pnp/core.c +1 -2
@@ -35,12 +35,11 @@ void *pnp_alloc(long size) {void *result; - result =kmalloc (size,GFP_KERNEL ); + result =kzalloc (size,GFP_KERNEL );if (!result){printk (KERN_ERR "pnp: Out of Memory\n" );return NULL ; } -memset (result,0 , size);return result; }
drivers/rapidio/rio-scan.c +2 -4
@@ -297,11 +297,10 @@ static struct rio_dev *rio_setup_device(struct rio_switch *rswitch;int result, rdid; - rdev =kmalloc (sizeof (struct rio_dev ),GFP_KERNEL ); + rdev =kzalloc (sizeof (struct rio_dev ),GFP_KERNEL );if (!rdev) goto out; -memset (rdev,0 ,sizeof (struct rio_dev )); rdev->net = net;rio_mport_read_config_32 (port, destid, hopcount,RIO_DEV_ID_CAR , &result);
@@ -801,9 +800,8 @@ static struct rio_net __devinit *rio_all {struct rio_net *net; - net =kmalloc (sizeof (struct rio_net ),GFP_KERNEL ); + net =kzalloc (sizeof (struct rio_net ),GFP_KERNEL );if (net) { -memset (net,0 ,sizeof (struct rio_net ));INIT_LIST_HEAD (&net->node);INIT_LIST_HEAD (&net->devices);INIT_LIST_HEAD (&net->mports);
drivers/s390/char/tape_34xx.c +1 -2
@@ -131,10 +131,9 @@ tape_34xx_schedule_work(struct tape_devi {struct tape_34xx_work *p; -if ((p =kmalloc (sizeof (*p),GFP_ATOMIC )) ==NULL ) +if ((p =kzalloc (sizeof (*p),GFP_ATOMIC )) ==NULL )return -ENOMEM ; -memset (p,0 ,sizeof (*p));INIT_WORK (&p->work, tape_34xx_work_handler); p->device =tape_get_device_reference (device);
drivers/s390/net/claw.c +3 -6
@@ -317,8 +317,8 @@ #endifCLAW_DBF_TEXT_ (2 ,setup,"probex%d" ,-ENOMEM );return -ENOMEM ; } - privptr->p_mtc_envelope=kmalloc (MAX_ENVELOPE_SIZE ,GFP_KERNEL ); - privptr->p_env =kmalloc (sizeof (struct claw_env ),GFP_KERNEL ); + privptr->p_mtc_envelope=kzalloc (MAX_ENVELOPE_SIZE ,GFP_KERNEL ); + privptr->p_env =kzalloc (sizeof (struct claw_env ),GFP_KERNEL );if ((privptr->p_mtc_envelope==NULL ) || (privptr->p_env==NULL )) {probe_error (cgdev);put_device (&cgdev->dev);
@@ -327,8 +327,6 @@ #endifCLAW_DBF_TEXT_ (2 ,setup,"probex%d" ,-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->host_name,WS_NAME_NOT_DEF ,8 );memcpy (privptr->p_env->api_type,WS_NAME_NOT_DEF ,8 );
@@ -3924,7 +3922,7 @@ #endifsnprintf (p_ch->id,CLAW_ID_SIZE ,"cl-%s" , cdev->dev.bus_id);ccw_device_get_id (cdev, &dev_id); 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" , p_ch->id,__FUNCTION__);#ifdef FUNCTRACE
@@ -3933,7 +3931,6 @@ #ifdef FUNCTRACE#endif return -ENOMEM ; } -memset (p_ch->irb,0 ,sizeof (struct irb ));#ifdef FUNCTRACE printk (KERN_INFO "%s:%s Exit on line %d\n" , cdev->dev.bus_id,__FUNCTION__,__LINE__);
drivers/s390/scsi/zfcp_erp.c +1 -2
@@ -1626,7 +1626,7 @@ zfcp_erp_schedule_work(struct zfcp_unit {struct zfcp_erp_add_work *p; - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p) {ZFCP_LOG_NORMAL ("error: Out of resources. Could not register " "the FCP-LUN 0x%Lx connected to "
@@ -1639,7 +1639,6 @@ zfcp_erp_schedule_work(struct zfcp_unit }zfcp_unit_get (unit); -memset (p,0 ,sizeof (*p));atomic_set_mask (ZFCP_STATUS_UNIT_SCSI_WORK_PENDING , &unit->status);INIT_WORK (&p->work, zfcp_erp_scsi_scan); p->unit = unit;
drivers/sbus/char/bbc_i2c.c +1 -2
@@ -156,10 +156,9 @@ struct bbc_i2c_client *bbc_i2c_attach(stif (!bp)return NULL ; - client =kmalloc (sizeof (*client),GFP_KERNEL ); + client =kzalloc (sizeof (*client),GFP_KERNEL );if (!client)return NULL ; -memset (client,0 ,sizeof (*client)); client->bp = bp; client->echild = echild; client->bus = echild->resource[0 ].start;
drivers/sbus/char/vfc_dev.c +1 -4
@@ -656,12 +656,9 @@ static int vfc_probe(void)if (!cards)return -ENODEV ; - vfc_dev_lst =kmalloc (sizeof (struct vfc_dev *) * - (cards+1 ), -GFP_KERNEL ); + vfc_dev_lst =kcalloc (sizeof (struct vfc_dev *), (cards+1 ),GFP_KERNEL );if (vfc_dev_lst ==NULL )return -ENOMEM ; -memset (vfc_dev_lst,0 ,sizeof (struct vfc_dev *) * (cards +1 )); vfc_dev_lst[cards] =NULL ; ret =register_chrdev (VFC_MAJOR , vfcstr, &vfc_fops);
drivers/scsi/3w-9xxx.c +1 -2
@@ -1160,13 +1160,12 @@ static int twa_initialize_device_extensi }/* Allocate event info space */ - tw_dev->event_queue[0 ] =kmalloc (sizeof (TW_Event) *TW_Q_LENGTH ,GFP_KERNEL ); + tw_dev->event_queue[0 ] =kcalloc (sizeof (TW_Event),TW_Q_LENGTH ,GFP_KERNEL );if (!tw_dev->event_queue[0 ]) {TW_PRINTK (tw_dev->host,TW_DRIVER ,0x18 ,"Event info memory allocation failed" ); goto out; } -memset (tw_dev->event_queue[0 ],0 ,sizeof (TW_Event) *TW_Q_LENGTH );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)));
drivers/scsi/NCR53C9x.c +1 -2
@@ -3606,11 +3606,10 @@ #endifint esp_slave_alloc (struct scsi_device *SDptr) {struct esp_device *esp_dev = -kmalloc (sizeof (struct esp_device ),GFP_ATOMIC ); +kzalloc (sizeof (struct esp_device ),GFP_ATOMIC );if (!esp_dev)return -ENOMEM ; -memset (esp_dev,0 ,sizeof (struct esp_device )); SDptr->hostdata = esp_dev;return 0 ; }
drivers/scsi/NCR_D700.c +1 -2
@@ -181,13 +181,12 @@ NCR_D700_probe_one(struct NCR_D700_privastruct Scsi_Host *host;int ret; - hostdata =kmalloc (sizeof (*hostdata),GFP_KERNEL ); + hostdata =kzalloc (sizeof (*hostdata),GFP_KERNEL );if (!hostdata) {printk (KERN_ERR "NCR D700: SIOP%d: Failed to allocate host" "data, detatching\n" , siop);return -ENOMEM ; } -memset (hostdata,0 ,sizeof (*hostdata));if (!request_region (region,64 ,"NCR_D700" )) { printk(KERN_ERR "NCR D700: Failed to reserve IO region 0x%x\n",
drivers/scsi/NCR_Q720.c +1 -2
@@ -148,11 +148,10 @@ NCR_Q720_probe(struct device *dev)__u32 base_addr, mem_size;void __iomem *mem_base; - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)return -ENOMEM ; -memset (p,0 ,sizeof (*p)); pos2 =mca_device_read_pos (mca_dev,2 );/* enable device */ pos2 |=NCR_Q720_POS2_BOARD_ENABLE |NCR_Q720_POS2_INTERRUPT_ENABLE ;
drivers/scsi/aacraid/aachba.c +1 -3
@@ -312,11 +312,9 @@ int aac_get_containers(struct aac_dev *dif (maximum_num_containers <MAXIMUM_NUM_CONTAINERS ) maximum_num_containers =MAXIMUM_NUM_CONTAINERS ; - fsa_dev_ptr =kmalloc (sizeof (*fsa_dev_ptr) * maximum_num_containers, -GFP_KERNEL ); + fsa_dev_ptr =kcalloc (sizeof (*fsa_dev_ptr), maximum_num_containers,GFP_KERNEL );if (!fsa_dev_ptr)return -ENOMEM ; -memset (fsa_dev_ptr,0 ,sizeof (*fsa_dev_ptr) * maximum_num_containers); dev->fsa_dev = fsa_dev_ptr; dev->maximum_num_containers = maximum_num_containers;
drivers/scsi/imm.c +1 -2
@@ -1159,11 +1159,10 @@ static int __imm_attach(struct parport *init_waitqueue_head (&waiting); - dev =kmalloc (sizeof (imm_struct),GFP_KERNEL ); + dev =kzalloc (sizeof (imm_struct),GFP_KERNEL );if (!dev)return -ENOMEM ; -memset (dev,0 ,sizeof (imm_struct)); dev->base =-1 ; dev->mode =IMM_AUTODETECT ;
drivers/scsi/ips.c +1 -2
@@ -7236,14 +7236,13 @@ ips_init_phase1(struct pci_dev *pci_dev, subdevice_id = pci_dev->subsystem_device;/* found a controller */ - ha =kmalloc (sizeof (ips_ha_t),GFP_KERNEL ); + ha =kzalloc (sizeof (ips_ha_t),GFP_KERNEL );if (ha ==NULL ) {IPS_PRINTK (KERN_WARNING , pci_dev,"Unable to allocate temporary ha struct\n" );return -1 ; } -memset (ha,0 ,sizeof (ips_ha_t)); ips_sh[index] =NULL ; ips_ha[index] = ha;
drivers/scsi/lasi700.c +1 -2
@@ -101,13 +101,12 @@ lasi700_probe(struct parisc_device *dev)struct NCR_700_Host_Parameters *hostdata;struct Scsi_Host *host; - hostdata =kmalloc (sizeof (*hostdata),GFP_KERNEL ); + hostdata =kzalloc (sizeof (*hostdata),GFP_KERNEL );if (!hostdata) {printk (KERN_ERR "%s: Failed to allocate host data\n" , dev->dev.bus_id);return -ENOMEM ; } -memset (hostdata,0 ,sizeof (struct NCR_700_Host_Parameters )); hostdata->dev = &dev->dev;dma_set_mask (&dev->dev,DMA_32BIT_MASK );
drivers/scsi/lpfc/lpfc_init.c +1 -2
@@ -1634,7 +1634,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev,/* Initialize and populate the iocb list per host. */ INIT_LIST_HEAD (&phba->lpfc_iocb_list);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 ) { printk(KERN_ERR "%s: only allocated %d iocbs of " "expected %d count. Unloading driver.\n",
@@ -1643,7 +1643,6 @@ lpfc_pci_probe_one(struct pci_dev *pdev, goto out_free_iocbq; } -memset (iocbq_entry,0 ,sizeof (struct lpfc_iocbq )); iotag =lpfc_sli_next_iotag (phba, iocbq_entry);if (iotag ==0 ) {kfree (iocbq_entry);
drivers/scsi/lpfc/lpfc_scsi.c +1 -2
@@ -59,10 +59,9 @@ lpfc_new_scsi_buf(struct lpfc_hba * phbadma_addr_t pdma_phys;uint16_t iotag; - psb =kmalloc (sizeof (struct lpfc_scsi_buf ),GFP_KERNEL ); + psb =kzalloc (sizeof (struct lpfc_scsi_buf ),GFP_KERNEL );if (!psb)return NULL ; -memset (psb,0 ,sizeof (struct lpfc_scsi_buf )); psb->scsi_hba = phba;/*
drivers/scsi/lpfc/lpfc_sli.c +1 -4
@@ -293,11 +293,8 @@ lpfc_sli_next_iotag(struct lpfc_hba * ph - LPFC_IOCBQ_LOOKUP_INCREMENT)) { new_len = psli->iocbq_lookup_len +LPFC_IOCBQ_LOOKUP_INCREMENT ;spin_unlock_irq (phba->host->host_lock); - new_arr =kmalloc (new_len *sizeof (struct lpfc_iocbq *), -GFP_KERNEL ); + new_arr =kcalloc (new_len,sizeof (struct lpfc_iocbq *),GFP_KERNEL );if (new_arr) { -memset ((char *)new_arr,0 , - new_len *sizeof (struct lpfc_iocbq *));spin_lock_irq (phba->host->host_lock); old_arr = psli->iocbq_lookup;if (new_len <= psli->iocbq_lookup_len) {
drivers/scsi/megaraid/megaraid_mbox.c +4 -10
@@ -454,7 +454,7 @@ megaraid_probe_one(struct pci_dev *pdev,pci_set_master (pdev);// Allocate the per driver initialization structure - adapter =kmalloc (sizeof (adapter_t),GFP_KERNEL ); + adapter =kzalloc (sizeof (adapter_t),GFP_KERNEL );if (adapter ==NULL ) { con_log(CL_ANN, (KERN_WARNING
@@ -462,7 +462,6 @@ megaraid_probe_one(struct pci_dev *pdev, goto out_probe_one; } -memset (adapter,0 ,sizeof (adapter_t));// 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 * 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 ; -memset (raid_dev,0 ,sizeof (mraid_device_t));/* * Attach the adapter soft state to raid device soft state
@@ -1050,8 +1048,7 @@ megaraid_alloc_cmd_packets(adapter_t *ad* since the calling routine does not yet know the number of available * commands. */ - adapter->kscb_list =kmalloc (sizeof (scb_t) *MBOX_MAX_SCSI_CMDS , -GFP_KERNEL ); + adapter->kscb_list =kcalloc (sizeof (scb_t),MBOX_MAX_SCSI_CMDS ,GFP_KERNEL );if (adapter->kscb_list ==NULL ) { con_log(CL_ANN, (KERN_WARNING
@@ -1059,7 +1056,6 @@ megaraid_alloc_cmd_packets(adapter_t *ad __LINE__)); goto out_free_ibuf; } -memset (adapter->kscb_list,0 ,sizeof (scb_t) *MBOX_MAX_SCSI_CMDS );// memory allocation for our command packets if (megaraid_mbox_setup_dma_pools (adapter) !=0 ) {
@@ -3572,8 +3568,7 @@ megaraid_cmm_register(adapter_t *adapterint i;// Allocate memory for the base list of scb for management module. - adapter->uscb_list =kmalloc (sizeof (scb_t) *MBOX_MAX_USER_CMDS , -GFP_KERNEL ); + adapter->uscb_list =kcalloc (sizeof (scb_t),MBOX_MAX_USER_CMDS ,GFP_KERNEL );if (adapter->uscb_list ==NULL ) { con_log(CL_ANN, (KERN_WARNING
@@ -3581,7 +3576,6 @@ megaraid_cmm_register(adapter_t *adapter __LINE__));return -1 ; } -memset (adapter->uscb_list,0 ,sizeof (scb_t) *MBOX_MAX_USER_CMDS );// Initialize the synchronization parameters for resources for
drivers/scsi/megaraid/megaraid_mm.c +1 -2
@@ -890,12 +890,11 @@ mraid_mm_register_adp(mraid_mmadp_t *lldif (lld_adp->drvr_type !=DRVRTYPE_MBOX )return (-EINVAL ); - adapter =kmalloc (sizeof (mraid_mmadp_t),GFP_KERNEL ); + adapter =kzalloc (sizeof (mraid_mmadp_t),GFP_KERNEL );if (!adapter)return -ENOMEM ; -memset (adapter,0 ,sizeof (mraid_mmadp_t)); adapter->unique_id = lld_adp->unique_id; adapter->drvr_type = lld_adp->drvr_type;
drivers/scsi/megaraid/megaraid_sas.c +1 -3
@@ -1714,15 +1714,13 @@ static int megasas_alloc_cmds(struct meg* Allocate the dynamic array first and then allocate individual * commands. */ - instance->cmd_list =kmalloc (sizeof (struct megasas_cmd *) * max_cmd, -GFP_KERNEL ); + instance->cmd_list =kcalloc (sizeof (struct megasas_cmd *), max_cmd,GFP_KERNEL );if (!instance->cmd_list) {printk (KERN_DEBUG "megasas: out of memory\n" );return -ENOMEM ; } -memset (instance->cmd_list,0 ,sizeof (struct megasas_cmd *) * max_cmd);for (i =0 ; i < max_cmd; i++) { instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),
drivers/scsi/pcmcia/aha152x_stub.c +1 -2
@@ -106,9 +106,8 @@ static int aha152x_probe(struct pcmcia_dDEBUG (0 ,"aha152x_attach()\n" );/* Create new SCSI device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (*info)); info->p_dev = link; link->priv = info;
drivers/scsi/pcmcia/nsp_cs.c +1 -2
@@ -1602,9 +1602,8 @@ static int nsp_cs_probe(struct pcmcia_densp_dbg (NSP_DEBUG_INIT ,"in" );/* Create new SCSI device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (info ==NULL ) {return -ENOMEM ; } -memset (info,0 ,sizeof (*info)); info->p_dev = link; link->priv = info; data->ScsiInfo = info;
drivers/scsi/pcmcia/qlogic_stub.c +1 -2
@@ -162,10 +162,9 @@ static int qlogic_probe(struct pcmcia_deDEBUG (0 ,"qlogic_attach()\n" );/* Create new SCSI device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (*info)); info->p_dev = link; link->priv = info; link->io.NumPorts1 =16 ;
drivers/scsi/pcmcia/sym53c500_cs.c +1 -2
@@ -879,10 +879,9 @@ SYM53C500_probe(struct pcmcia_device *liDEBUG (0 ,"SYM53C500_attach()\n" );/* Create new SCSI device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (*info)); info->p_dev = link; link->priv = info; link->io.NumPorts1 =16 ;
drivers/scsi/ppa.c +1 -2
@@ -1017,10 +1017,9 @@ static int __ppa_attach(struct parport *int modes, ppb, ppb_hi;int err = -ENOMEM ; - dev =kmalloc (sizeof (ppa_struct),GFP_KERNEL ); + dev =kzalloc (sizeof (ppa_struct),GFP_KERNEL );if (!dev)return -ENOMEM ; -memset (dev,0 ,sizeof (ppa_struct)); dev->base =-1 ; dev->mode =PPA_AUTODETECT ; dev->recon_tmo =PPA_RECON_TMO ;
drivers/scsi/sim710.c +1 -2
@@ -100,7 +100,7 @@ sim710_probe_common(struct device *dev, {struct Scsi_Host * host =NULL ;struct NCR_700_Host_Parameters *hostdata = -kmalloc (sizeof (struct NCR_700_Host_Parameters ),GFP_KERNEL ); +kzalloc (sizeof (struct NCR_700_Host_Parameters ),GFP_KERNEL );printk (KERN_NOTICE "sim710: %s\n" , dev->bus_id); printk(KERN_NOTICE "sim710: irq = %d, clock = %d, base = 0x%lx, scsi_id = %d\n",
@@ -110,7 +110,6 @@ sim710_probe_common(struct device *dev,printk (KERN_ERR "sim710: Failed to allocate host data\n" ); goto out; } -memset (hostdata,0 ,sizeof (struct NCR_700_Host_Parameters ));if (request_region (base_addr,64 ,"sim710" ) ==NULL ) { printk(KERN_ERR "sim710: Failed to reserve IO region 0x%lx\n",
drivers/scsi/tmscsim.c +1 -2
@@ -2101,10 +2101,9 @@ static int dc390_slave_alloc(struct scsiuint id = scsi_device->id;uint lun = scsi_device->lun; - pDCB =kmalloc (sizeof (struct dc390_dcb ),GFP_KERNEL ); + pDCB =kzalloc (sizeof (struct dc390_dcb ),GFP_KERNEL );if (!pDCB)return -ENOMEM ; -memset (pDCB,0 ,sizeof (struct dc390_dcb ));if (!pACB->DCBCnt++) { pACB->pLinkDCB = pDCB;
drivers/serial/amba-pl011.c +1 -2
@@ -716,7 +716,7 @@ static int pl011_probe(struct amba_devic goto out; } - uap =kmalloc (sizeof (struct uart_amba_port ),GFP_KERNEL ); + uap =kzalloc (sizeof (struct uart_amba_port ),GFP_KERNEL );if (uap ==NULL ) { ret = -ENOMEM ; goto out;
@@ -728,7 +728,6 @@ static int pl011_probe(struct amba_devic goto free; } -memset (uap,0 ,sizeof (struct uart_amba_port )); uap->clk =clk_get (&dev->dev,"UARTCLK" );if (IS_ERR (uap->clk)) { ret =PTR_ERR (uap->clk);
drivers/sh/superhyway/superhyway.c +1 -2
@@ -56,11 +56,10 @@ int superhyway_add_device(unsigned longstruct superhyway_device *dev = sdev;if (!dev) { - dev =kmalloc (sizeof (struct superhyway_device ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct superhyway_device ),GFP_KERNEL );if (!dev)return -ENOMEM ; -memset (dev,0 ,sizeof (struct superhyway_device )); } dev->bus = bus;
drivers/sn/ioc3.c +1 -2
@@ -629,7 +629,7 @@ #ifdef USE_64BIT_DMA#endif /* Set up per-IOC3 data */ - idd =kmalloc (sizeof (struct ioc3_driver_data ),GFP_KERNEL ); + idd =kzalloc (sizeof (struct ioc3_driver_data ),GFP_KERNEL );if (!idd) { printk(KERN_WARNING "%s: Failed to allocate IOC3 data for pci_dev %s.\n",
@@ -637,7 +637,6 @@ #endif ret = -ENODEV ; goto out_idd; } -memset (idd,0 ,sizeof (struct ioc3_driver_data ));spin_lock_init (&idd->ir_lock);spin_lock_init (&idd->gpio_lock); idd->pdev = pdev;
drivers/telephony/ixj_pcmcia.c +1 -2
@@ -45,11 +45,10 @@ static int ixj_probe(struct pcmcia_devic p_dev->io.Attributes2 =IO_DATA_PATH_WIDTH_8 ; p_dev->io.IOAddrLines =3 ; p_dev->conf.IntType =INT_MEMORY_AND_IO ; - p_dev->priv =kmalloc (sizeof (struct ixj_info_t ),GFP_KERNEL ); + p_dev->priv =kzalloc (sizeof (struct ixj_info_t ),GFP_KERNEL );if (!p_dev->priv) {return -ENOMEM ; } -memset (p_dev->priv,0 ,sizeof (struct ixj_info_t ));return ixj_config (p_dev); }
drivers/usb/gadget/goku_udc.c +1 -2
@@ -1827,14 +1827,13 @@ static int goku_probe(struct pci_dev *pd }/* alloc, and start init */ - dev =kmalloc (sizeof *dev,GFP_KERNEL ); + dev =kzalloc (sizeof *dev,GFP_KERNEL );if (dev ==NULL ){pr_debug ("enomem %s\n" ,pci_name (pdev)); retval = -ENOMEM ; goto done; } -memset (dev,0 ,sizeof *dev);spin_lock_init (&dev->lock); dev->pdev = pdev; dev->gadget.ops = &goku_ops;
drivers/usb/gadget/serial.c +1 -2
@@ -1427,7 +1427,7 @@ #endif /* CONFIG_USB_GADGET_DUALSPEED */ gs_acm_config_desc.bmAttributes |=USB_CONFIG_ATT_WAKEUP ; } - gs_device = dev =kmalloc (sizeof (struct gs_dev ),GFP_KERNEL ); + gs_device = dev =kzalloc (sizeof (struct gs_dev ),GFP_KERNEL );if (dev ==NULL )return -ENOMEM ;
@@ -1435,7 +1435,6 @@ #endif /* CONFIG_USB_GADGET_DUALSPEED */init_utsname ()->sysname,init_utsname ()->release, gadget->name); -memset (dev,0 ,sizeof (struct gs_dev )); dev->dev_gadget = gadget;spin_lock_init (&dev->dev_lock);INIT_LIST_HEAD (&dev->dev_req_list);
drivers/usb/host/ohci-hcd.c +1 -2
@@ -171,11 +171,10 @@ #endif }/* allocate the private part of the URB */ - urb_priv =kmalloc (sizeof (urb_priv_t) + size *sizeof (struct td *), + urb_priv =kzalloc (sizeof (urb_priv_t) + size *sizeof (struct td *), mem_flags);if (!urb_priv)return -ENOMEM ; -memset (urb_priv,0 ,sizeof (urb_priv_t) + size *sizeof (struct td *));INIT_LIST_HEAD (&urb_priv->pending); urb_priv->length = size; urb_priv->ed = ed;
drivers/usb/host/sl811_cs.c +1 -2
@@ -278,10 +278,9 @@ static int sl811_cs_probe(struct pcmcia_ {local_info_t *local; - local =kmalloc (sizeof (local_info_t),GFP_KERNEL ); + local =kzalloc (sizeof (local_info_t),GFP_KERNEL );if (!local)return -ENOMEM ; -memset (local,0 ,sizeof (local_info_t)); local->p_dev = link; link->priv = local;
drivers/usb/misc/ftdi-elan.c +1 -2
@@ -2774,12 +2774,11 @@ static int ftdi_elan_probe(struct usb_insize_t buffer_size;int i;int retval = -ENOMEM ; -struct usb_ftdi *ftdi =kmalloc (sizeof (struct usb_ftdi ),GFP_KERNEL ); +struct usb_ftdi *ftdi =kzalloc (sizeof (struct usb_ftdi ),GFP_KERNEL );if (ftdi ==NULL ) {printk (KERN_ERR "Out of memory\n" );return -ENOMEM ; } -memset (ftdi,0x00 ,sizeof (struct usb_ftdi ));down (&ftdi_module_lock);list_add_tail (&ftdi->ftdi_list, &ftdi_static_list); ftdi->sequence_num = ++ftdi_instances;
drivers/video/amba-clcd.c +1 -2
@@ -447,13 +447,12 @@ static int clcdfb_probe(struct amba_devi goto out; } - fb =kmalloc (sizeof (struct clcd_fb ),GFP_KERNEL ); + fb =kzalloc (sizeof (struct clcd_fb ),GFP_KERNEL );if (!fb) {printk (KERN_INFO "CLCD: could not allocate new clcd_fb struct\n" ); ret = -ENOMEM ; goto free_region; } -memset (fb,0 ,sizeof (struct clcd_fb )); fb->dev = dev; fb->board = board;
drivers/video/aty/atyfb_base.c +1 -2
@@ -2937,12 +2937,11 @@ static int __devinit atyfb_setup_sparc(s/* nothing */ ; j = i +4 ; - par->mmap_map =kmalloc (j *sizeof (*par->mmap_map),GFP_ATOMIC ); + par->mmap_map =kcalloc (j,sizeof (*par->mmap_map),GFP_ATOMIC );if (!par->mmap_map) {PRINTKE ("atyfb_setup_sparc() can't alloc mmap_map\n" );return -ENOMEM ; } -memset (par->mmap_map,0 , j *sizeof (*par->mmap_map));for (i =0 , j =2 ; i <6 && pdev->resource[i].start; i++) {struct resource *rp = &pdev->resource[i];
drivers/video/au1200fb.c +1 -2
@@ -1589,11 +1589,10 @@ static int au1200fb_init_fbinfo(struct areturn -EFAULT ; } - fbi->pseudo_palette =kmalloc (sizeof (u32) *16 ,GFP_KERNEL ); + fbi->pseudo_palette =kcalloc (sizeof (u32),16 ,GFP_KERNEL );if (!fbi->pseudo_palette) {return -ENOMEM ; } -memset (fbi->pseudo_palette,0 ,sizeof (u32) *16 );if (fb_alloc_cmap (&fbi->cmap,AU1200_LCD_NBR_PALETTE_ENTRIES ,0 ) <0 ) { print_err("Fail to allocate colormap (%d entries)",
drivers/video/clps711xfb.c +1 -2
@@ -366,11 +366,10 @@ int __init clps711xfb_init(void)if (fb_get_options ("clps711xfb" ,NULL ))return -ENODEV ; - cfb =kmalloc (sizeof (*cfb),GFP_KERNEL ); + cfb =kzalloc (sizeof (*cfb),GFP_KERNEL );if (!cfb) goto out; -memset (cfb,0 ,sizeof (*cfb));strcpy (cfb->fix.id,"clps711x" ); cfb->fbops = &clps7111fb_ops;
drivers/video/cyber2000fb.c +1 -2
@@ -1221,11 +1221,10 @@ cyberpro_alloc_fb_info(unsigned int id, {struct cfb_info *cfb; - cfb =kmalloc (sizeof (struct cfb_info ),GFP_KERNEL ); + cfb =kzalloc (sizeof (struct cfb_info ),GFP_KERNEL );if (!cfb)return NULL ; -memset (cfb,0 ,sizeof (struct cfb_info )); cfb->id = id;
drivers/video/offb.c +1 -2
@@ -273,13 +273,12 @@ static void __init offb_init_fb(const ch size =sizeof (struct fb_info ) +sizeof (u32) *17 ; - info =kmalloc (size,GFP_ATOMIC ); + info =kzalloc (size,GFP_ATOMIC );if (info ==0 ) {release_mem_region (res_start, res_size);return ; } -memset (info,0 , size); fix = &info->fix; var = &info->var;
drivers/video/pvr2fb.c +1 -2
@@ -1085,13 +1085,12 @@ #ifndef MODULE#endif size =sizeof (struct fb_info ) +sizeof (struct pvr2fb_par ) +16 *sizeof (u32); - fb_info =kmalloc (size,GFP_KERNEL ); + fb_info =kzalloc (size,GFP_KERNEL );if (!fb_info) {printk (KERN_ERR "Failed to allocate memory for fb_info\n" );return -ENOMEM ; } -memset (fb_info,0 , size); currentpar = (struct pvr2fb_par *)(fb_info +1 );
drivers/video/savage/savagefb_driver.c +1 -2
@@ -2174,11 +2174,10 @@ static int __devinit savage_init_fb_info#if defined(CONFIG_FB_SAVAGE_ACCEL )/* FIFO size + padding for commands */ - info->pixmap.addr =kmalloc (8 *1024 ,GFP_KERNEL ); + info->pixmap.addr =kcalloc (8 ,1024 ,GFP_KERNEL ); err = -ENOMEM ;if (info->pixmap.addr) { -memset (info->pixmap.addr,0 ,8 *1024 ); info->pixmap.size =8 *1024 ; info->pixmap.scan_align =4 ; info->pixmap.buf_align =4 ;
drivers/video/valkyriefb.c +1 -2
@@ -356,10 +356,9 @@ #else /* ppc (!CONFIG_MAC) */ }#endif /* ppc (!CONFIG_MAC) */ - p =kmalloc (sizeof (*p),GFP_ATOMIC ); + p =kzalloc (sizeof (*p),GFP_ATOMIC );if (p ==0 )return -ENOMEM ; -memset (p,0 ,sizeof (*p));/* Map in frame buffer and registers */ if (!request_mem_region (frame_buffer_phys,0x100000 ,"valkyriefb" )) {
drivers/w1/masters/matrox_w1.c +1 -2
@@ -164,7 +164,7 @@ static int __devinit matrox_w1_probe(strif (pdev->vendor !=PCI_VENDOR_ID_MATROX || pdev->device !=PCI_DEVICE_ID_MATROX_G400 )return -ENODEV ; - dev =kmalloc (sizeof (struct matrox_device ) + + dev =kzalloc (sizeof (struct matrox_device ) +sizeof (struct w1_bus_master ),GFP_KERNEL );if (!dev) { dev_err(&pdev->dev,
@@ -173,7 +173,6 @@ static int __devinit matrox_w1_probe(strreturn -ENOMEM ; } -memset (dev,0 ,sizeof (struct matrox_device ) +sizeof (struct w1_bus_master )); dev->bus_master = (struct w1_bus_master *)(dev +1 );
drivers/w1/slaves/w1_ds2433.c +1 -2
@@ -265,10 +265,9 @@ static int w1_f23_add_slave(struct w1_sl#ifdef CONFIG_W1_SLAVE_DS2433_CRC struct w1_f23_data *data; - data =kmalloc (sizeof (struct w1_f23_data ),GFP_KERNEL ); + data =kzalloc (sizeof (struct w1_f23_data ),GFP_KERNEL );if (!data)return -ENOMEM ; -memset (data,0 ,sizeof (struct w1_f23_data )); sl->family_data = data;#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
drivers/w1/w1.c +1 -2
@@ -516,7 +516,7 @@ static int w1_attach_slave_device(structint err;struct w1_netlink_msg msg; - sl =kmalloc (sizeof (struct w1_slave ),GFP_KERNEL ); + sl =kzalloc (sizeof (struct w1_slave ),GFP_KERNEL );if (!sl) { dev_err(&dev->dev, "%s: failed to allocate new slave device.\n",
@@ -524,7 +524,6 @@ static int w1_attach_slave_device(structreturn -ENOMEM ; } -memset (sl,0 ,sizeof (*sl)); sl->owner =THIS_MODULE ; sl->master = dev;
drivers/w1/w1_int.c +1 -2
@@ -41,7 +41,7 @@ static struct w1_master * w1_alloc_dev(u/* * We are in process context(kernel thread), so can sleep. */ - dev =kmalloc (sizeof (struct w1_master ) +sizeof (struct w1_bus_master ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct w1_master ) +sizeof (struct w1_bus_master ),GFP_KERNEL );if (!dev) { printk(KERN_ERR "Failed to allocate %zd bytes for new w1 device.\n",
@@ -49,7 +49,6 @@ static struct w1_master * w1_alloc_dev(ureturn NULL ; } -memset (dev,0 ,sizeof (struct w1_master ) +sizeof (struct w1_bus_master )); dev->bus_master = (struct w1_bus_master *)(dev +1 );
fs/dlm/memory.c +3 -9
@@ -39,9 +39,7 @@ char *allocate_lvb(struct dlm_ls *ls) {char *p; - p =kmalloc (ls->ls_lvblen,GFP_KERNEL ); -if (p) -memset (p,0 , ls->ls_lvblen); + p =kzalloc (ls->ls_lvblen,GFP_KERNEL );return p; }
@@ -59,9 +57,7 @@ struct dlm_rsb *allocate_rsb(struct dlm_ DLM_ASSERT(namelen <= DLM_RESNAME_MAXLEN,); - r =kmalloc (sizeof (*r) + namelen,GFP_KERNEL ); -if (r) -memset (r,0 ,sizeof (*r) + namelen); + r =kzalloc (sizeof (*r) + namelen,GFP_KERNEL );return r; }
@@ -101,9 +97,7 @@ struct dlm_direntry *allocate_direntry(sDLM_ASSERT (namelen <=DLM_RESNAME_MAXLEN , printk("namelen = %d\n", namelen);); - de =kmalloc (sizeof (*de) + namelen,GFP_KERNEL ); -if (de) -memset (de,0 ,sizeof (*de) + namelen); + de =kzalloc (sizeof (*de) + namelen,GFP_KERNEL );return de; }
fs/ext2/super.c +1 -3
@@ -882,13 +882,11 @@ #endif goto failed_mount; }bgl_lock_init (&sbi->s_blockgroup_lock); - sbi->s_debts =kmalloc (sbi->s_groups_count *sizeof (*sbi->s_debts), -GFP_KERNEL ); + sbi->s_debts =kcalloc (sbi->s_groups_count,sizeof (*sbi->s_debts),GFP_KERNEL );if (!sbi->s_debts) {printk ("EXT2-fs: not enough memory\n" ); goto failed_mount_group_desc; } -memset (sbi->s_debts,0 , sbi->s_groups_count *sizeof (*sbi->s_debts));for (i =0 ; i < db_count; i++) { block =descriptor_loc (sb, logic_sb_block, i); sbi->s_group_desc[i] =sb_bread (sb, block);
fs/partitions/check.c +1 -2
@@ -372,11 +372,10 @@ void add_partition(struct gendisk *disk, {struct hd_struct *p; - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)return ; -memset (p,0 ,sizeof (*p)); p->start_sect = start; p->nr_sects = len; p->partno = part;
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +1 -2
@@ -182,7 +182,7 @@ static int ct_open(struct inode *inode,struct ct_iter_state *st;int ret; - st =kmalloc (sizeof (struct ct_iter_state ),GFP_KERNEL ); + st =kzalloc (sizeof (struct ct_iter_state ),GFP_KERNEL );if (st ==NULL )return -ENOMEM ; ret =seq_open (file, &ct_seq_ops);
@@ -190,7 +190,6 @@ static int ct_open(struct inode *inode, goto out_free; seq = file->private_data; seq->private = st; -memset (st,0 ,sizeof (struct ct_iter_state ));return ret; out_free:kfree (st);
net/mac80211/ieee80211_rate.c +1 -2
@@ -24,11 +24,10 @@ int ieee80211_rate_control_register(stru {struct rate_control_alg *alg; - alg =kmalloc (sizeof (*alg),GFP_KERNEL ); + alg =kzalloc (sizeof (*alg),GFP_KERNEL );if (alg ==NULL ) {return -ENOMEM ; } -memset (alg,0 ,sizeof (*alg)); alg->ops = ops;mutex_lock (&rate_ctrl_mutex);
net/mac80211/ieee80211_sta.c +1 -2
@@ -1282,10 +1282,9 @@ ieee80211_rx_bss_add(struct net_device *struct ieee80211_local *local =wdev_priv (dev->ieee80211_ptr);struct ieee80211_sta_bss *bss; - bss =kmalloc (sizeof (*bss),GFP_ATOMIC ); + bss =kzalloc (sizeof (*bss),GFP_ATOMIC );if (!bss)return NULL ; -memset (bss,0 ,sizeof (*bss));atomic_inc (&bss->users);atomic_inc (&bss->users);memcpy (bss->bssid, bssid,ETH_ALEN );
net/netfilter/nf_conntrack_standalone.c +1 -2
@@ -203,7 +203,7 @@ static int ct_open(struct inode *inode,struct ct_iter_state *st;int ret; - st =kmalloc (sizeof (struct ct_iter_state ),GFP_KERNEL ); + st =kzalloc (sizeof (struct ct_iter_state ),GFP_KERNEL );if (st ==NULL )return -ENOMEM ; ret =seq_open (file, &ct_seq_ops);
@@ -211,7 +211,6 @@ static int ct_open(struct inode *inode, goto out_free; seq = file->private_data; seq->private = st; -memset (st,0 ,sizeof (struct ct_iter_state ));return ret; out_free:kfree (st);
net/tipc/name_table.c +1 -2
@@ -1052,12 +1052,11 @@ int tipc_nametbl_init(void) {int array_size =sizeof (struct hlist_head ) * tipc_nametbl_size; - table.types =kmalloc (array_size,GFP_ATOMIC ); + table.types =kzalloc (array_size,GFP_ATOMIC );if (!table.types)return -ENOMEM ;write_lock_bh (&tipc_nametbl_lock); -memset (table.types,0 , array_size); table.local_publ_count =0 ;write_unlock_bh (&tipc_nametbl_lock);return 0 ;
sound/core/seq/seq_virmidi.c +1 -2
@@ -363,7 +363,7 @@ static int snd_virmidi_dev_attach_seq(stif (rdev->client >=0 )return 0 ; - pinfo =kmalloc (sizeof (*pinfo),GFP_KERNEL ); + pinfo =kzalloc (sizeof (*pinfo),GFP_KERNEL );if (!pinfo) { err = -ENOMEM ; goto __error;
@@ -380,7 +380,6 @@ static int snd_virmidi_dev_attach_seq(st rdev->client = client;/* create a port */ -memset (pinfo,0 ,sizeof (*pinfo)); pinfo->addr.client = client;sprintf (pinfo->name,"VirMIDI %d-%d" , rdev->card->number, rdev->device);/* set all capabilities */
Quoted 3 lines · Yoann Padioleau
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Christoph, what is the plan wrt GFP_ZERO?
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Quoted 6 lines · Peter Zijlstra
Quoted 3 lines · Yoann Padioleau
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Christoph, what is the plan wrt
GFP_ZERO?
Its going in AFAIK. Need to resort my patches and then I will push it back.
kzalloc will continue to exist as a shorthand notation. So no problem with continuing the conversion. kmalloc with GFP_ZERO may be more advantageous in allocator type functionality where the caller may want to specify if the allocated memory should be zeroed or not.
_______________________________________________
REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with
"subscribe kernel-janitors" in message body and follow instructions.
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Quoted 2 lines
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
I looked all the files through. They looked good to me, except one case:
In drivers/net/hamradio/dmascc.c you removed one comment, and I think it should not be removed:
/* Initialize what is necessary for write_scc and write_scc_data */
Signature · 11 lines
Heikki Orsila Barbie's law: [email protected] "Math is hard, let's go shopping!" http://www.iki.fi/shd _______________________________________________ REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with "subscribe kernel-janitors" in message body and follow instructions. Kernel-janitors mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Quoted 5 lines · Heikki Orsila
Quoted 2 lines
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
I looked all the files through. They looked good to me, except one case:
I checked the drivers/net and net/ changes and they looked ok (aside from the above).
- James
Signature · 10 lines
James Morris <[email protected]> _______________________________________________ REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with "subscribe kernel-janitors" in message body and follow instructions. Kernel-janitors mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Quoted 12 lines · On Fri, 6 Jul 2007 18:07:20 -0400 (EDT) James Morris <[email protected]> wrote:
Quoted 5 lines · Heikki Orsila
Quoted 2 lines
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
I looked all the files through. They looked good to me, except one case:
I checked the
drivers/netandnet/changes and they looked ok (aside from the above).
OK, thanks for checking it, guys.
Yoann, the "tree wide" thing really is a problem. Your patch here is touching ten or more maintainers' code and it really does want to be split into ten separate patches and fed into the tree via the appropriate routes.
I can take care of that routing if I have the ten patches, but this time I really can't be bothered splitting the patch up (it's rather boring, and gets error-prone).
For this patch, I tossed out the ten or so hunks which conflicted with other pending patches in the various trees and I shall just grit the teeth and maintain and merge it as a single whopping patch. (At least this way I'll actually get some scsi stuff merged). Anything which conflicts with anyone's outstanding work will be dropped.
For any future patches, _please_ split them up along some sane lines. Generally you'll find that one patch per second-level directory works pretty well: drivers/net, drivers/scsi, drivers/usb, fs/ext2, drivers/char, etc.
Thanks.
_______________________________________________
REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with
"subscribe kernel-janitors" in message body and follow instructions.
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Am 06.07.2007 18:51 schrieb Yoann Padioleau:
Quoted 6 lines
@@
expression E1,E2,E3;
@@-
kzalloc(E1 * E2,E3)
+kcalloc(E1,E2,E3)
This misses the semantic distinction between the first and second arguments of kcalloc(). The first argument is supposed to be the number of elements to allocate and the second their size. As a consequence, the following hunks in your pathc are wrong:
Quoted 260 lines
arch/arm/mach-iop13xx/pci.c +1
-2@@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pciif (nr >1 )return 0 ; - res =kmalloc (sizeof (struct resource ) *2 ,GFP_KERNEL ); + res =kcalloc (sizeof (struct resource ),2 ,GFP_KERNEL );if (!res)panic ("PCI: unable to alloc resources" ); -memset (res,0 ,sizeof (struct resource ) *2 );/* 'nr' assumptions: * ATUX is always 0 drivers/char/drm/via_dmablit.c +1
-2@@ -273,10 +273,9 @@ via_alloc_desc_pages(drm_via_sg_info_t * vsg->num_desc_pages = (vsg->num_desc + vsg->descriptors_per_page -1 ) / vsg->descriptors_per_page; -if (NULL == (vsg->desc_pages =kmalloc (sizeof (void *) * vsg->num_desc_pages,GFP_KERNEL ))) +if (NULL == (vsg->desc_pages =kcalloc (sizeof (void *), vsg->num_desc_pages,GFP_KERNEL )))return DRM_ERR (ENOMEM ); -memset (vsg->desc_pages,0 ,sizeof (void *) * vsg->num_desc_pages); vsg->state = dr_via_desc_pages_alloc; for (i=0; i<vsg->num_desc_pages; ++i) { if (NULL == (vsg->desc_pages[i] =drivers/net/forcedeth.c +2
-4@@ -4995,12 +4995,10 @@ static int __devinit nv_probe(struct pci goto out_unmap; 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->tx_skb =kmalloc (sizeof (struct nv_skb_map ) * np->tx_ring_size,GFP_KERNEL ); + np->rx_skb =kcalloc (sizeof (struct nv_skb_map ), np->rx_ring_size,GFP_KERNEL ); + np->tx_skb =kcalloc (sizeof (struct nv_skb_map ), np->tx_ring_size,GFP_KERNEL );if (!np->rx_skb || !np->tx_skb) 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->stop = nv_close;drivers/net/wan/cosa.c +1
-3@@ -572,13 +572,11 @@ #endifsprintf (cosa->name,"cosa%d" , cosa->num);/* Initialize the per-channel data */ - cosa->chan =kmalloc (sizeof (struct channel_data )*cosa->nchannels, -GFP_KERNEL ); + cosa->chan =kcalloc (sizeof (struct channel_data ), cosa->nchannels,GFP_KERNEL );if (!cosa->chan) { err = -ENOMEM ; goto err_out3; } -memset (cosa->chan,0 ,sizeof (struct channel_data )*cosa->nchannels);for (i=0 ; i<cosa->nchannels; i++) { cosa->chan[i].cosa = cosa; cosa->chan[i].num = i;drivers/net/wan/cycx_main.c +1
-3@@ -113,12 +113,10 @@ static int __init cycx_init(void)/* Verify number of cards and allocate adapter data space */ cycx_ncards =min_t (int, cycx_ncards,CYCX_MAX_CARDS ); cycx_ncards =max_t (int, cycx_ncards,1 ); - cycx_card_array =kmalloc (sizeof (struct cycx_device ) * cycx_ncards, -GFP_KERNEL ); + cycx_card_array =kcalloc (sizeof (struct cycx_device ), cycx_ncards,GFP_KERNEL );if (!cycx_card_array) goto out; -memset (cycx_card_array,0 ,sizeof (struct cycx_device ) * cycx_ncards);/* Register adapters with WAN router */ for (cnt =0 ; cnt < cycx_ncards; ++cnt) {drivers/net/wan/x25_asy.c +1
-3@@ -786,14 +786,12 @@ static int __init init_x25_asy(void)printk (KERN_INFO "X.25 async: version 0.00 ALPHA " "(dynamic channels, max=%d).\n" , x25_asy_maxdev ); - x25_asy_devs =kmalloc (sizeof (struct net_device *)*x25_asy_maxdev, -GFP_KERNEL ); + x25_asy_devs =kcalloc (sizeof (struct net_device *), x25_asy_maxdev,GFP_KERNEL );if (!x25_asy_devs) {printk (KERN_WARNING "X25 async: Can't allocate x25_asy_ctrls[] " "array! Uaargh! (-> No X.25 available)\n" );return -ENOMEM ; } -memset (x25_asy_devs,0 ,sizeof (struct net_device *)*x25_asy_maxdev);return tty_register_ldisc (N_X25 , &x25_ldisc); }drivers/sbus/char/vfc_dev.c +1
-4@@ -656,12 +656,9 @@ static int vfc_probe(void)if (!cards)return -ENODEV ; - vfc_dev_lst =kmalloc (sizeof (struct vfc_dev *) * - (cards+1 ), -GFP_KERNEL ); + vfc_dev_lst =kcalloc (sizeof (struct vfc_dev *), (cards+1 ),GFP_KERNEL );if (vfc_dev_lst ==NULL )return -ENOMEM ; -memset (vfc_dev_lst,0 ,sizeof (struct vfc_dev *) * (cards +1 )); vfc_dev_lst[cards] =NULL ; ret =register_chrdev (VFC_MAJOR , vfcstr, &vfc_fops);drivers/scsi/3w-9xxx.c +1
-2@@ -1160,13 +1160,12 @@ static int twa_initialize_device_extensi }/* Allocate event info space */ - tw_dev->event_queue[0 ] =kmalloc (sizeof (TW_Event) *TW_Q_LENGTH ,GFP_KERNEL ); + tw_dev->event_queue[0 ] =kcalloc (sizeof (TW_Event),TW_Q_LENGTH ,GFP_KERNEL );if (!tw_dev->event_queue[0 ]) {TW_PRINTK (tw_dev->host,TW_DRIVER ,0x18 ,"Event info memory allocation failed" ); goto out; } -memset (tw_dev->event_queue[0 ],0 ,sizeof (TW_Event) *TW_Q_LENGTH );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)));drivers/scsi/aacraid/aachba.c +1
-3@@ -312,11 +312,9 @@ int aac_get_containers(struct aac_dev *dif (maximum_num_containers <MAXIMUM_NUM_CONTAINERS ) maximum_num_containers =MAXIMUM_NUM_CONTAINERS ; - fsa_dev_ptr =kmalloc (sizeof (*fsa_dev_ptr) * maximum_num_containers, -GFP_KERNEL ); + fsa_dev_ptr =kcalloc (sizeof (*fsa_dev_ptr), maximum_num_containers,GFP_KERNEL );if (!fsa_dev_ptr)return -ENOMEM ; -memset (fsa_dev_ptr,0 ,sizeof (*fsa_dev_ptr) * maximum_num_containers); dev->fsa_dev = fsa_dev_ptr; dev->maximum_num_containers = maximum_num_containers;drivers/scsi/megaraid/megaraid_mbox.c +2
-6@@ -1050,8 +1048,7 @@ megaraid_alloc_cmd_packets(adapter_t *ad* since the calling routine does not yet know the number of available * commands. */ - adapter->kscb_list =kmalloc (sizeof (scb_t) *MBOX_MAX_SCSI_CMDS , -GFP_KERNEL ); + adapter->kscb_list =kcalloc (sizeof (scb_t),MBOX_MAX_SCSI_CMDS ,GFP_KERNEL );if (adapter->kscb_list ==NULL ) { con_log(CL_ANN, (KERN_WARNING@@ -1059,7 +1056,6 @@ megaraid_alloc_cmd_packets(adapter_t *ad __LINE__)); goto out_free_ibuf; } -memset (adapter->kscb_list,0 ,sizeof (scb_t) *MBOX_MAX_SCSI_CMDS );// memory allocation for our command packets if (megaraid_mbox_setup_dma_pools (adapter) !=0 ) {@@ -3572,8 +3568,7 @@ megaraid_cmm_register(adapter_t *adapterint i;// Allocate memory for the base list of scb for management module. - adapter->uscb_list =kmalloc (sizeof (scb_t) *MBOX_MAX_USER_CMDS , -GFP_KERNEL ); + adapter->uscb_list =kcalloc (sizeof (scb_t),MBOX_MAX_USER_CMDS ,GFP_KERNEL );if (adapter->uscb_list ==NULL ) { con_log(CL_ANN, (KERN_WARNING@@ -3581,7 +3576,6 @@ megaraid_cmm_register(adapter_t *adapter __LINE__));return -1 ; } -memset (adapter->uscb_list,0 ,sizeof (scb_t) *MBOX_MAX_USER_CMDS );// Initialize the synchronization parameters for resources for drivers/scsi/megaraid/megaraid_sas.c +1
-3@@ -1714,15 +1714,13 @@ static int megasas_alloc_cmds(struct meg* Allocate the dynamic array first and then allocate individual * commands. */ - instance->cmd_list =kmalloc (sizeof (struct megasas_cmd *) * max_cmd, -GFP_KERNEL ); + instance->cmd_list =kcalloc (sizeof (struct megasas_cmd *), max_cmd,GFP_KERNEL );if (!instance->cmd_list) {printk (KERN_DEBUG "megasas: out of memory\n" );return -ENOMEM ; } -memset (instance->cmd_list,0 ,sizeof (struct megasas_cmd *) * max_cmd);for (i =0 ; i < max_cmd; i++) { instance->cmd_list[i] = kmalloc(sizeof(struct megasas_cmd),drivers/video/au1200fb.c +1
-2@@ -1589,11 +1589,10 @@ static int au1200fb_init_fbinfo(struct areturn -EFAULT ; } - fbi->pseudo_palette =kmalloc (sizeof (u32) *16 ,GFP_KERNEL ); + fbi->pseudo_palette =kcalloc (sizeof (u32),16 ,GFP_KERNEL );if (!fbi->pseudo_palette) {return -ENOMEM ; } -memset (fbi->pseudo_palette,0 ,sizeof (u32) *16 );if (fb_alloc_cmap (&fbi->cmap,AU1200_LCD_NBR_PALETTE_ENTRIES ,0 ) <0 ) { print_err("Fail to allocate colormap (%d entries)",drivers/video/savage/savagefb_driver.c +0
-0@@ -2174,11 +2174,10 @@ static int __devinit savage_init_fb_info#if defined(CONFIG_FB_SAVAGE_ACCEL )
drivers/video/savage/savagefb_driver.c static int __devinit savage_init_fb_info · line 2183
Quoted 10 lines
drivers/video/savage/savagefb_driver.c +1
-2/* FIFO size + padding for commands */ - info->pixmap.addr =kmalloc (8 *1024 ,GFP_KERNEL ); + info->pixmap.addr =kcalloc (8 ,1024 ,GFP_KERNEL ); err = -ENOMEM ;if (info->pixmap.addr) { -memset (info->pixmap.addr,0 ,8 *1024 ); info->pixmap.size =8 *1024 ; info->pixmap.scan_align =4 ; info->pixmap.buf_align =4 ;
HTH
Signature · 3 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany Please excuse my bad English/German/French/Greek/Cantonese/Klingon/...
Quoted 5 lines · Tilman Schmidt
Am 06.07.2007 18:51 schrieb Yoann Padioleau:
Quoted 4 lines
@@
expression E1,E2,E3;
@@
Quoted 7 lines
Quoted 2 lines
-
kzalloc(E1 * E2,E3)
+kcalloc(E1,E2,E3)This misses the semantic distinction between the first and second arguments of
kcalloc(). The first argument is supposed to be the number of elements to allocate and the second their size. As a consequence, the following hunks in your pathc are wrong:
Yes you are right. Andrew Morton fixed the problem in a subsequent patch.
I should have written a more precise semantic patch such as
@@
expression E;
constant c;
type T;
@@
- kzalloc(sizeof(T) * c, E)
+ kcalloc(c, sizeof(T), E)
Note that sometimes the code is written as kzalloc(c * sizeof(T), E)
as in kzalloc(2 * sizeof(struct resource), GFP_KERNEL) but
our transformation engine can handle the commutativity of '*' and still performs the right transformation.
Quoted 15 lines
Quoted 15 lines
arch/arm/mach-iop13xx/ renamed from arch/arm/mach-iop13xx/pci.c +0
-0
pci.c
index 9d63d7f..b84955f 100644arch/arm/mach-iop13xx/pci.c +1
-1@@ -1002,11 +1002,10 @@ int iop13xx_pci_setup(int nr, struct pciif (nr >1 )return 0 ; - res =kmalloc (sizeof (struct resource ) *2 ,GFP_KERNEL ); + res =kcalloc (sizeof (struct resource ),2 ,GFP_KERNEL );if (!res)panic ("PCI: unable to alloc resources" );
Quoted 5 lines
arch/arm/mach-iop13xx/pci.c int iop13xx_pci_setup(int nr, struct pci · line 1011
Quoted 4 lines
arch/arm/mach-iop13xx/pci.c +0
-1-memset (res,0 ,sizeof (struct resource ) *2 );/* 'nr' assumptions: * ATUX is always 0
_______________________________________________
REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with
"subscribe kernel-janitors" in message body and follow instructions.
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Am 07.07.2007 15:36 schrieb yoann padioleau:
Quoted 9 lines · Tilman Schmidt
Quoted 5 lines
This misses the semantic distinction between the first and second arguments of
kcalloc(). The first argument is supposed to be the number of elements to allocate and the second their size. As a consequence, the following hunks in your pathc are wrong:Yes you are right. Andrew Morton fixed the problem in a subsequent patch.
That's ok then. Andrew is doing an awesome job.
Quoted 8 lines
I should have written a more precise semantic patch such as
@@
expression E;
constant c;
type T;
@@
Quoted 7 lines
-
kzalloc(sizeof(T) * c, E)
+kcalloc(c, sizeof(T), E)Note that sometimes the code is written as
kzalloc(c * sizeof(T), E)
as inkzalloc(2 * sizeof(struct resource), GFP_KERNEL)but
our transformation engine can handle the commutativity of '*' and still performs the right transformation.
Cool. That transformation engine sure sounds like an interesting piece of code.
Regards,
Tilman
Signature · 4 lines
Tilman Schmidt E-Mail: [email protected] Bonn, Germany Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
Quoted 4 lines · Yoann Padioleau
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
Here is a short excerpt of the semantic patch performing this transformation:
Cool!
Documentation/connector/cn_test.c static void cn_test_timer_func(unsigned · line 131
Quoted 13 lines
Documentation/connector/cn_test.c +1
-2@@ -124,9 +124,8 @@ static void cn_test_timer_func(unsignedstruct cn_msg *m;char data[32 ]; - m =kmalloc (sizeof (*m) +sizeof (data),GFP_ATOMIC ); + m =kzalloc (sizeof (*m) +sizeof (data),GFP_ATOMIC );if (m) { -memset (m,0 ,sizeof (*m) +sizeof (data));memcpy (&m->id, &cn_test_id,sizeof (m->id)); m->seq = cn_test_timer_counter;
Such empty lines (after memset) [c|s]hould also go.
Quoted 4 lines
index e83f1db..deb7b6a 100644
block/scsi_ioctl.c int sg_scsi_ioctl(struct file *file, str · line 412
Quoted 10 lines
block/scsi_ioctl.c +1
-2@@ -405,11 +405,10 @@ int sg_scsi_ioctl(struct file *file, str bytes =max (in_len, out_len);if (bytes) { - buffer =kmalloc (bytes, q->bounce_gfp |GFP_USER | __GFP_NOWARN); + buffer =kzalloc (bytes, q->bounce_gfp |GFP_USER | __GFP_NOWARN);if (!buffer)return -ENOMEM ; -memset (buffer,0 , bytes); }
And in this case, empty line before memset.
(Either of - do not let remove empty lines in both directoriens around memset)
block/scsi_ioctl.c #endif · line 1621
Quoted 8 lines
block/scsi_ioctl.c +0
-1@@ -1616,7 +1616,6 @@ #endif goto err_out_regions; } -memset (host,0 ,sizeof (*host)); host->pdev = pdev; host->flags = pci_dac ?FL_DAC :0 ;spin_lock_init (&host->lock);
And in this case, no blank lines should be removed.
These are just suggestions. If it is too much work, leave it as-is. :)
Jan
Signature · 8 lines
_______________________________________________ REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with "subscribe kernel-janitors" in message body and follow instructions. Kernel-janitors mailing list [email protected] https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors
Yoann Padioleau <[email protected]> ha scritto:
Quoted 2 lines
Transform some calls to kmalloc/memset to a single kzalloc (or kcalloc).
[...]
Quoted 5 lines
arch/alpha/kernel/module.c +0
-0
arch/alpha/kernel/module.c module_frob_arch_sections(Elf64_Ehdr *hd · line 125
Quoted 9 lines
arch/alpha/kernel/module.c +1
-2@@ -119,8 +119,7 @@ module_frob_arch_sections(Elf64_Ehdr *hd } nsyms = symtab->sh_size /sizeof (Elf64_Sym); - chains =kmalloc (nsyms *sizeof (struct got_entry ),GFP_KERNEL ); -memset (chains,0 , nsyms *sizeof (struct got_entry )); + chains =kcalloc (nsyms,sizeof (struct got_entry ),GFP_KERNEL ); got->sh_size =0 ; got->sh_addralign =8 ;
Unrelated to the conversion, but here Alpha module loader is dereferencing 'chains' without checking the outcome of the kmalloc().
Quoted 5 lines
drivers/char/rio/riotable.c +0
-0
drivers/char/rio/riotable.c int RIOReMapPorts(struct rio_info *p, st · line 869
Quoted 9 lines
drivers/char/rio/riotable.c +1
-2@@ -863,8 +863,7 @@ int RIOReMapPorts(struct rio_info *p, stif (PortP->TxRingBuffer)memset (PortP->TxRingBuffer,0 , p->RIOBufferSize);else if (p->RIOBufferSize) { - PortP->TxRingBuffer =kmalloc (p->RIOBufferSize,GFP_KERNEL ); -memset (PortP->TxRingBuffer,0 , p->RIOBufferSize); + PortP->TxRingBuffer =kzalloc (p->RIOBufferSize,GFP_KERNEL ); } PortP->TxBufferOut =0 ; PortP->TxBufferIn =0 ;
Same here.
drivers/char/synclinkmp.c static SLMP_INFO *alloc_dev(int adapter_ · line 3798
Quoted 11 lines
drivers/char/synclinkmp.c +1
-1@@ -3794,14 +3794,13 @@ static SLMP_INFO *alloc_dev(int adapter_ {SLMP_INFO *info; - info =kmalloc (sizeof (SLMP_INFO ), + info =kzalloc (sizeof (SLMP_INFO ),GFP_KERNEL );
Funny indentation :)
drivers/macintosh/smu.c static int smu_open(struct inode *inode, · line 1058
Quoted 12 lines
drivers/macintosh/smu.c +1
-1@@ -1053,10 +1053,9 @@ static int smu_open(struct inode *inode,struct smu_private *pp;unsigned long flags; - pp =kmalloc (sizeof (struct smu_private ),GFP_KERNEL ); + pp =kzalloc (sizeof (struct smu_private ),GFP_KERNEL );if (pp ==0 )return -ENOMEM ;
s/0/NULL/
Quoted 10 lines
drivers/macintosh/smu.c +0
-1-memset (pp,0 ,sizeof (struct smu_private ));spin_lock_init (&pp->lock); pp->mode = smu_file_commands;init_waitqueue_head (&pp->wait);drivers/macintosh/therm_windtunnel.c +0
-0
drivers/macintosh/therm_windtunnel.c do_probe( struct i2c_adapter *adapter, i · line 436
Quoted 7 lines
drivers/macintosh/therm_windtunnel.c +1
-2@@ -431,9 +431,8 @@ do_probe( struct i2c_adapter *adapter, i | I2C_FUNC_SMBUS_WRITE_BYTE) )return 0 ; -if ( !(cl=kmalloc (sizeof (*cl),GFP_KERNEL )) ) +if ( !(cl=kzalloc (sizeof (*cl),GFP_KERNEL )) )return -ENOMEM ; -memset ( cl,0 ,sizeof (struct i2c_client ) );
This - following the common style - should be:
cl = kzalloc(sizeof(*cl), GFP_KERNEL);
if (!cl)
return -ENOMEM;
drivers/media/dvb/cinergyT2/cinergyT2.c static int cinergyt2_probe (struct usb_i · line 911
Quoted 13 lines
drivers/media/dvb/cinergyT2/cinergyT2.c +1
-1@@ -905,12 +905,11 @@ static int cinergyt2_probe (struct usb_istruct cinergyt2 *cinergyt2;int err; -if (!(cinergyt2 =kmalloc (sizeof (struct cinergyt2 ),GFP_KERNEL ))) { +if (!(cinergyt2 =kzalloc (sizeof (struct cinergyt2 ),GFP_KERNEL ))) {dprintk (1 ,"out of memory?!?\n" );return -ENOMEM ; }
Ditto.
drivers/media/video/planb.c static int planb_prepare_open(struct pla · line 357
Quoted 11 lines
drivers/media/video/planb.c +1
-1@@ -353,9 +353,8 @@ static int planb_prepare_open(struct pla * PLANB_DUMMY)*sizeof(struct dbdma_cmd) +(PLANB_MAXLINES *((PLANB_MAXPIXELS +7 )& ~7 ))/8 +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 ;
Ditto.
Quoted 9 lines
drivers/media/video/planb.c +0
-1-memset ((void *) pb->priv_space,0 , size); pb->overlay_last1 = pb->ch1_cmd = (volatile struct dbdma_cmd *)DBDMA_ALIGN (pb->priv_space); pb->overlay_last2 = pb->ch2_cmd = pb->ch1_cmd + pb->tab_size;drivers/media/video/usbvideo/vicam.c +0
-0
drivers/media/video/usbvideo/vicam.c vicam_probe( struct usb_interface *intf, · line 1308
Quoted 5 lines
drivers/media/video/usbvideo/vicam.c +1
-1@@ -1305,13 +1305,12 @@ vicam_probe( struct usb_interface *intf, }if ((cam = -kmalloc (sizeof (struct vicam_camera ),GFP_KERNEL )) ==NULL ) { +kzalloc (sizeof (struct vicam_camera ),GFP_KERNEL )) ==NULL ) {
Ditto, plus this one is ugly :)
drivers/media/video/zr364xx.c static int zr364xx_probe(struct usb_inte · line 803
Quoted 10 lines
drivers/media/video/zr364xx.c +1
-1@@ -800,11 +800,10 @@ static int zr364xx_probe(struct usb_inte udev->descriptor.idProduct);if ((cam = -kmalloc (sizeof (struct zr364xx_camera ),GFP_KERNEL )) ==NULL ) { +kzalloc (sizeof (struct zr364xx_camera ),GFP_KERNEL )) ==NULL ) {
Ditto.
drivers/net/bsd_comp.c static void *bsd_alloc (unsigned char *o · line 399
Quoted 11 lines
drivers/net/bsd_comp.c +1
-1@@ -395,14 +395,13 @@ static void *bsd_alloc (unsigned char *o* Allocate the main control structure for this instance. */ maxmaxcode =MAXCODE (bits); - db =kmalloc (sizeof (struct bsd_db ), + db =kzalloc (sizeof (struct bsd_db ),GFP_KERNEL );
Identation?
drivers/net/pcmcia/ibmtr_cs.c static int __devinit ibmtr_attach(struct · line 150
Quoted 11 lines
drivers/net/pcmcia/ibmtr_cs.c +1
-1@@ -146,9 +146,8 @@ static int __devinit ibmtr_attach(structDEBUG (0 ,"ibmtr_attach()\n" );/* Create new token-ring device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ;
Fix the return statement while you are at it.
drivers/net/ppp_async.c ppp_asynctty_open(struct tty_struct *tty · line 164
Quoted 12 lines
drivers/net/ppp_async.c +1
-1@@ -159,12 +159,11 @@ ppp_asynctty_open(struct tty_struct *ttyint err; err = -ENOMEM ; - ap =kmalloc (sizeof (*ap),GFP_KERNEL ); + ap =kzalloc (sizeof (*ap),GFP_KERNEL );if (ap ==0 ) goto out;
NULL, not 0.
drivers/net/ppp_deflate.c static void *z_comp_alloc(unsigned char · line 125
Quoted 11 lines
drivers/net/ppp_deflate.c +1
-1@@ -121,12 +121,11 @@ static void *z_comp_alloc(unsigned charif (w_size <DEFLATE_MIN_SIZE || w_size >DEFLATE_MAX_SIZE )return NULL ; - state =kmalloc (sizeof (*state), + state =kzalloc (sizeof (*state),GFP_KERNEL );
Style
drivers/net/ppp_synctty.c ppp_sync_open(struct tty_struct *tty) · line 213
Quoted 13 lines
drivers/net/ppp_synctty.c +1
-1@@ -207,13 +207,12 @@ ppp_sync_open(struct tty_struct *tty)struct syncppp *ap;int err; - ap =kmalloc (sizeof (*ap),GFP_KERNEL ); + ap =kzalloc (sizeof (*ap),GFP_KERNEL ); err = -ENOMEM ;if (ap ==0 ) goto out;
NULL
drivers/nubus/nubus.c static struct nubus_dev* __init · line 471
Quoted 12 lines
drivers/nubus/nubus.c +1
-2@@ -466,9 +466,8 @@ static struct nubus_dev* __init parent->base, dir.base);/* 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 ; -memset (dev,0 ,sizeof (*dev));
Split maybe?
drivers/nubus/nubus.c static struct nubus_board* __init nubus_ · line 805
Quoted 11 lines
drivers/nubus/nubus.c +1
-2dev->resid = parent->type; dev->directory = dir.base; dev->board = board;@@ -800,9 +799,8 @@ static struct nubus_board* __init nubus_nubus_rewind (&rp,FORMAT_BLOCK_SIZE , bytelanes);/* 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 ; -memset (board,0 ,sizeof (*board));
Same here.
drivers/pci/pcie/aer/aerdrv.c static struct aer_rpc* aer_alloc_rpc(str · line 153
Quoted 12 lines
drivers/pci/pcie/aer/aerdrv.c +1
-1@@ -148,11 +148,10 @@ static struct aer_rpc* aer_alloc_rpc(str {struct aer_rpc *rpc; -if (!(rpc =kmalloc (sizeof (struct aer_rpc ), +if (!(rpc =kzalloc (sizeof (struct aer_rpc ),GFP_KERNEL )))return NULL ;
Ditto, plus the indentation looks strange.
drivers/s390/char/tape_34xx.c tape_34xx_schedule_work(struct tape_devi · line 135
Quoted 11 lines
drivers/s390/char/tape_34xx.c +1
-1@@ -131,10 +131,9 @@ tape_34xx_schedule_work(struct tape_devi {struct tape_34xx_work *p; -if ((p =kmalloc (sizeof (*p),GFP_ATOMIC )) ==NULL ) +if ((p =kzalloc (sizeof (*p),GFP_ATOMIC )) ==NULL )return -ENOMEM ;
Two lines.
drivers/s390/net/claw.c #endif · line 324
Quoted 13 lines
drivers/s390/net/claw.c +2
-2@@ -317,8 +317,8 @@ #endifCLAW_DBF_TEXT_ (2 ,setup,"probex%d" ,-ENOMEM );return -ENOMEM ; } - privptr->p_mtc_envelope=kmalloc (MAX_ENVELOPE_SIZE ,GFP_KERNEL ); - privptr->p_env =kmalloc (sizeof (struct claw_env ),GFP_KERNEL ); + privptr->p_mtc_envelope=kzalloc (MAX_ENVELOPE_SIZE ,GFP_KERNEL ); + privptr->p_env =kzalloc (sizeof (struct claw_env ),GFP_KERNEL );if ((privptr->p_mtc_envelope==NULL ) || (privptr->p_env==NULL )) {probe_error (cgdev);put_device (&cgdev->dev);
On the error path this driver may leak the memory allocated by the first kmalloc (in case only the second fails).
drivers/scsi/pcmcia/aha152x_stub.c static int aha152x_probe(struct pcmcia_d · line 110
Quoted 11 lines
drivers/scsi/pcmcia/aha152x_stub.c +1
-1@@ -106,9 +106,8 @@ static int aha152x_probe(struct pcmcia_dDEBUG (0 ,"aha152x_attach()\n" );/* Create new SCSI device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (!info)return -ENOMEM ;
Style
Quoted 9 lines
drivers/scsi/pcmcia/aha152x_stub.c +0
-1-memset (info,0 ,sizeof (*info)); info->p_dev = link; link->priv = info;drivers/scsi/pcmcia/nsp_cs.c +0
-0
drivers/scsi/pcmcia/nsp_cs.c static int nsp_cs_probe(struct pcmcia_de · line 1606
Quoted 6 lines
drivers/scsi/pcmcia/nsp_cs.c +1
-1@@ -1602,9 +1602,8 @@ static int nsp_cs_probe(struct pcmcia_densp_dbg (NSP_DEBUG_INIT ,"in" );/* Create new SCSI device */ - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (info ==NULL ) {return -ENOMEM ; }
Style
Luca
Signature · 2 lines
Il coraggio non mi manca. E` la paura che mi frega...