kzalloc() conversion in drivers/video
Subsystems (42)
PATCH 1/1 kzalloc() conversion in drivers/video
hi,
this patch converts drivers/video to kzalloc usage.
Compile tested with allyes config. It also contains a formating change in video/matrox/matroxfb_maven.c, i am not sure if it is ok to remove the cast, to keep it on a single line to make it more readable.
drivers/video/au1100fb.c renamed from drivers/video/au1100fb.c.orig +2 -5
@@ -444,11 +444,10 @@ int au1100fb_drv_probe(struct device *dereturn -EINVAL ;/* Allocate new device private */ -if (!(fbdev =kmalloc (sizeof (struct au1100fb_device ),GFP_KERNEL ))) { +if (!(fbdev =kzalloc (sizeof (struct au1100fb_device ),GFP_KERNEL ))) {print_err ("fail to allocate device private record" );return -ENOMEM ; } -memset ((void *)fbdev,0 ,sizeof (struct au1100fb_device )); fbdev->panel = &known_lcd_panels[drv_info.panel_idx];
@@ -525,10 +524,8 @@ int au1100fb_drv_probe(struct device *de fbdev->info.fbops = &au1100fb_ops; fbdev->info.fix = au1100fb_fix; -if (!(fbdev->info.pseudo_palette =kmalloc (sizeof (u32) *16 ,GFP_KERNEL ))) { +if (!(fbdev->info.pseudo_palette =kcalloc (16 ,sizeof (u32),GFP_KERNEL )))return -ENOMEM ; - } -memset (fbdev->info.pseudo_palette,0 ,sizeof (u32) *16 );if (fb_alloc_cmap (&fbdev->info.cmap,AU1100_LCD_NBR_PALETTE_ENTRIES ,0 ) <0 ) { print_err("Fail to allocate colormap (%d entries)",
drivers/video/matrox/matroxfb_crtc2.c renamed from drivers/video/matrox/matroxfb_crtc2.c.orig +1 -2
@@ -694,12 +694,11 @@ static void* matroxfb_crtc2_probe(struct/* hardware is CRTC2 incapable... */ if (!ACCESS_FBINFO (devflags.crtc2))return NULL ; - m2info = (struct matroxfb_dh_fb_info *)kmalloc (sizeof (*m2info),GFP_KERNEL ); + m2info = (struct matroxfb_dh_fb_info *)kzalloc (sizeof (*m2info),GFP_KERNEL );if (!m2info) {printk (KERN_ERR "matroxfb_crtc2: Not enough memory for CRTC2 control structs\n" );return NULL ; } -memset (m2info,0 ,sizeof (*m2info)); m2info->primary_dev =MINFO ;if (matroxfb_dh_registerfb (m2info)) {kfree (m2info);
drivers/video/matrox/matroxfb_maven.c renamed from drivers/video/matrox/matroxfb_maven.c.orig +4 -3
@@ -1243,12 +1243,13 @@ static int maven_detect_client(struct i2 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_PROTOCOL_MANGLING)) goto ERROR0; -if (!(new_client = (struct i2c_client *)kmalloc (sizeof (*new_client) +sizeof (*data), -GFP_KERNEL ))) { + + new_client = (struct i2c_client *)kzalloc (sizeof (*new_client) +sizeof (*data), +GFP_KERNEL ); +if (!new_client) { err = -ENOMEM ; goto ERROR0; } -memset (new_client,0 ,sizeof (*new_client) +sizeof (*data)); data = (struct maven_data *)(new_client +1 );i2c_set_clientdata (new_client, data); new_client->addr = address;
drivers/video/cg14.c renamed from drivers/video/cg14.c.orig +1 -2
@@ -480,12 +480,11 @@ static void cg14_init_one(struct sbus_de } } - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "cg14: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/valkyriefb.c renamed from drivers/video/valkyriefb.c.orig +1 -2
@@ -359,10 +359,9 @@ int __init valkyriefb_init(void) }#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/video/cg3.c renamed from drivers/video/cg3.c.orig +1 -2
@@ -369,12 +369,11 @@ static void cg3_init_one(struct sbus_devstruct all_info *all;int linebytes; - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "cg3: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/aty/atyfb_base.c renamed from drivers/video/aty/atyfb_base.c.orig +1 -2
@@ -2853,12 +2853,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 =kzalloc (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/leo.c renamed from drivers/video/leo.c.orig +1 -2
@@ -541,12 +541,11 @@ static void leo_init_one(struct sbus_devstruct all_info *all;int linebytes; - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "leo: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/igafb.c renamed from drivers/video/igafb.c.orig +2 -5
@@ -404,12 +404,11 @@ int __init igafb_init(void) size =sizeof (struct fb_info ) +sizeof (struct iga_par ) +sizeof (u32)*16 ; - info =kmalloc (size,GFP_ATOMIC ); + info =kzalloc (size,GFP_ATOMIC );if (!info) {printk ("igafb_init: can't alloc fb_info\n" );return -ENOMEM ; } -memset (info,0 , size); par = (struct iga_par *) (info +1 );
@@ -468,7 +467,7 @@ int __init igafb_init(void)* one additional region with size == 0. */ - par->mmap_map =kmalloc (4 *sizeof (*par->mmap_map),GFP_ATOMIC ); + par->mmap_map =kzalloc (4 *sizeof (*par->mmap_map),GFP_ATOMIC );if (!par->mmap_map) {printk ("igafb_init: can't alloc mmap_map\n" );iounmap ((void *)par->io_base);
@@ -477,8 +476,6 @@ int __init igafb_init(void)return -ENOMEM ; } -memset (par->mmap_map,0 ,4 *sizeof (*par->mmap_map)); -/* * Set default vmode and cmode from PROM properties. */
drivers/video/bw2.c renamed from drivers/video/bw2.c.orig +1 -2
@@ -301,12 +301,11 @@ static void bw2_init_one(struct sbus_dev#endif int linebytes; - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "bw2: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/nvidia/nvidia.c renamed from drivers/video/nvidia/nvidia.c.orig +1 -3
@@ -1566,13 +1566,11 @@ static int __devinit nvidiafb_probe(stru par = info->par; par->pci_dev = pd; - info->pixmap.addr =kmalloc (8 *1024 ,GFP_KERNEL ); + info->pixmap.addr =kzalloc (8 *1024 ,GFP_KERNEL );if (info->pixmap.addr ==NULL ) goto err_out_kfree; -memset (info->pixmap.addr,0 ,8 *1024 ); -if (pci_enable_device (pd)) { printk(KERN_ERR PFX "cannot enable PCI device\n"); goto err_out_enable;
drivers/video/retz3fb.c renamed from drivers/video/retz3fb.c.orig +1 -2
@@ -1370,10 +1370,9 @@ int __init retz3fb_init(void)release_mem_region (board_addr,0x00c00000 );continue ; } -if (!(zinfo =kmalloc (sizeof (struct retz3_fb_info ), +if (!(zinfo =kzalloc (sizeof (struct retz3_fb_info ),GFP_KERNEL )))return -ENOMEM ; -memset (zinfo,0 ,sizeof (struct retz3_fb_info )); zinfo->base =ioremap (board_addr, board_size); zinfo->regs = zinfo->base;
drivers/video/tgafb.c renamed from drivers/video/tgafb.c.orig +1 -2
@@ -1396,12 +1396,11 @@ tgafb_pci_register(struct pci_dev *pdev, }/* Allocate the fb and par structures. */ - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "tgafb: Cannot allocate memory\n" );return -ENOMEM ; } -memset (all,0 ,sizeof (*all));pci_set_drvdata (pdev, all);/* Request the mem regions. */
drivers/video/i810/i810_main.c renamed from drivers/video/i810/i810_main.c.orig +1 -2
@@ -2012,11 +2012,10 @@ static int __devinit i810fb_init_pci (st par = info->par; par->dev = dev; -if (!(info->pixmap.addr =kmalloc (8 *1024 ,GFP_KERNEL ))) { +if (!(info->pixmap.addr =kzalloc (8 *1024 ,GFP_KERNEL ))) {i810fb_release_resource (info, par);return -ENOMEM ; } -memset (info->pixmap.addr,0 ,8 *1024 ); info->pixmap.size =8 *1024 ; info->pixmap.buf_align =8 ; info->pixmap.access_align =32 ;
drivers/video/clps711xfb.c renamed from drivers/video/clps711xfb.c.orig +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/controlfb.c renamed from drivers/video/controlfb.c.orig +1 -2
@@ -694,11 +694,10 @@ static int __init control_of_init(structprintk (KERN_ERR "can't get 2 addresses for control\n" );return -ENXIO ; } - p =kmalloc (sizeof (*p),GFP_KERNEL ); + p =kzalloc (sizeof (*p),GFP_KERNEL );if (p ==0 )return -ENXIO ; control_fb = p;/* save it for cleanups */ -memset (p,0 ,sizeof (*p));/* Map in frame buffer and registers */ p->fb_orig_base = fb_res.start;
drivers/video/cyber2000fb.c renamed from drivers/video/cyber2000fb.c.orig +1 -3
@@ -1223,12 +1223,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;if (id ==ID_CYBERPRO_5000 )
drivers/video/tcx.c renamed from drivers/video/tcx.c.orig +1 -2
@@ -359,12 +359,11 @@ static void tcx_init_one(struct sbus_devstruct all_info *all;int linebytes, i; - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "tcx: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/ffb.c renamed from drivers/video/ffb.c.orig +1 -2
@@ -940,12 +940,11 @@ static void ffb_init_one(int node, int preturn ; } - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "ffb: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/sun3fb.c renamed from drivers/video/sun3fb.c.orig +1 -2
@@ -526,11 +526,10 @@ static int __init sun3fb_init_fb(int fbtint linebytes, w, h, depth;char *p =NULL ; - fb =kmalloc (sizeof (struct fb_info_sbusfb ),GFP_ATOMIC ); + fb =kzalloc (sizeof (struct fb_info_sbusfb ),GFP_ATOMIC );if (!fb)return -ENOMEM ; -memset (fb,0 ,sizeof (struct fb_info_sbusfb )); fix = &fb->fix; var = &fb->var; disp = &fb->disp;
drivers/video/savage/savagefb_driver.c renamed from drivers/video/savage/savagefb_driver.c.orig +1 -2
@@ -1950,11 +1950,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 =kzalloc (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/riva/fbdev.c renamed from drivers/video/riva/fbdev.c.orig +1 -2
@@ -1888,12 +1888,11 @@ static int __devinit rivafb_probe(struct default_par = info->par; default_par->pdev = pd; - info->pixmap.addr =kmalloc (8 *1024 ,GFP_KERNEL ); + info->pixmap.addr =kzalloc (8 *1024 ,GFP_KERNEL );if (info->pixmap.addr ==NULL ) { ret = -ENOMEM ; goto err_framebuffer_release; } -memset (info->pixmap.addr,0 ,8 *1024 ); ret =pci_enable_device (pd);if (ret <0 ) {
drivers/video/cg6.c renamed from drivers/video/cg6.c.orig +1 -2
@@ -667,12 +667,11 @@ static void cg6_init_one(struct sbus_devstruct all_info *all;int linebytes; - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "cg6: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/p9100.c renamed from drivers/video/p9100.c.orig +1 -2
@@ -272,12 +272,11 @@ static void p9100_init_one(struct sbus_dstruct all_info *all;int linebytes; - all =kmalloc (sizeof (*all),GFP_KERNEL ); + all =kzalloc (sizeof (*all),GFP_KERNEL );if (!all) {printk (KERN_ERR "p9100: Cannot allocate memory.\n" );return ; } -memset (all,0 ,sizeof (*all));INIT_LIST_HEAD (&all->list);
drivers/video/intelfb/intelfbdrv.c renamed from drivers/video/intelfb/intelfbdrv.c.orig +1 -2
@@ -526,12 +526,11 @@ intelfb_pci_register(struct pci_dev *pde dinfo->pdev = pdev;/* Reserve pixmap space. */ - info->pixmap.addr =kmalloc (64 *1024 ,GFP_KERNEL ); + info->pixmap.addr =kzalloc (64 *1024 ,GFP_KERNEL );if (info->pixmap.addr ==NULL ) {ERR_MSG ("Cannot reserve pixmap memory.\n" ); goto err_out_pixmap; } -memset (info->pixmap.addr,0 ,64 *1024 );/* set early this option because it could be changed by tv encoder driver */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/atm
hi,
this patch converts drivers/video to kzalloc usage. Compile tested with allyes config.
drivers/atm/adummy.c renamed from drivers/atm/adummy.c.orig +2 -3
@@ -114,14 +114,13 @@ static int __init adummy_init(void)printk (KERN_ERR "adummy: version %s\n" ,DRV_VERSION ); - adummy_dev = (struct adummy_dev *)kmalloc (sizeof (struct adummy_dev ), + adummy_dev = (struct adummy_dev *)kzalloc (sizeof (struct adummy_dev ),GFP_KERNEL );if (!adummy_dev) { - printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n"); + printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n"); err = -ENOMEM ; goto out; } -memset (adummy_dev,0 ,sizeof (struct adummy_dev )); atm_dev =atm_dev_register (DEV_LABEL , &adummy_ops,-1 ,NULL );if (!atm_dev) {
drivers/atm/he.c renamed from drivers/atm/he.c.orig +1 -2
@@ -384,13 +384,12 @@ he_init_one(struct pci_dev *pci_dev, con }pci_set_drvdata (pci_dev, atm_dev); - he_dev = (struct he_dev *)kmalloc (sizeof (struct he_dev ), + he_dev = (struct he_dev *)kzalloc (sizeof (struct he_dev ),GFP_KERNEL );if (!he_dev) { err = -ENOMEM ; goto init_one_failure; } -memset (he_dev,0 ,sizeof (struct he_dev )); he_dev->pci_dev = pci_dev; he_dev->atm_dev = atm_dev;
drivers/atm/idt77252.c renamed from drivers/atm/idt77252.c.orig +6 -12
@@ -642,10 +642,9 @@ alloc_scq(struct idt77252_dev *card, int {struct scq_info *scq; - scq = (struct scq_info *)kmalloc (sizeof (struct scq_info ),GFP_KERNEL ); + scq = (struct scq_info *)kzalloc (sizeof (struct scq_info ),GFP_KERNEL );if (!scq)return NULL ; -memset (scq,0 ,sizeof (struct scq_info )); scq->base =pci_alloc_consistent (card->pcidev,SCQ_SIZE , &scq->paddr);
@@ -2142,10 +2141,9 @@ idt77252_init_est(struct vc_map *vc, int {struct rate_estimator *est; - est =kmalloc (sizeof (struct rate_estimator ),GFP_KERNEL ); + est =kzalloc (sizeof (struct rate_estimator ),GFP_KERNEL );if (!est)return NULL ; -memset (est,0 ,sizeof (*est)); est->maxcps = pcr <0 ? -pcr : pcr; est->cps = est->maxcps;
@@ -2451,13 +2449,12 @@ idt77252_open(struct atm_vcc *vcc) index =VPCI2VC (card, vpi, vci);if (!card->vcs[index]) { - card->vcs[index] =kmalloc (sizeof (struct vc_map ),GFP_KERNEL ); + card->vcs[index] =kzalloc (sizeof (struct vc_map ),GFP_KERNEL );if (!card->vcs[index]) {printk ("%s: can't alloc vc in open()\n" , card->name);up (&card->mutex);return -ENOMEM ; } -memset (card->vcs[index],0 ,sizeof (struct vc_map )); card->vcs[index]->card = card; card->vcs[index]->index = index;
@@ -2926,12 +2923,11 @@ open_card_oam(struct idt77252_dev *card)for (vci =3 ; vci <5 ; vci++) { index =VPCI2VC (card, vpi, vci); - vc =kmalloc (sizeof (struct vc_map ),GFP_KERNEL ); + vc =kzalloc (sizeof (struct vc_map ),GFP_KERNEL );if (!vc) {printk ("%s: can't alloc vc\n" , card->name);return -ENOMEM ; } -memset (vc,0 ,sizeof (struct vc_map )); vc->index = index; card->vcs[index] = vc;
@@ -2995,12 +2991,11 @@ open_card_ubr0(struct idt77252_dev *card {struct vc_map *vc; - vc =kmalloc (sizeof (struct vc_map ),GFP_KERNEL ); + vc =kzalloc (sizeof (struct vc_map ),GFP_KERNEL );if (!vc) {printk ("%s: can't alloc vc\n" , card->name);return -ENOMEM ; } -memset (vc,0 ,sizeof (struct vc_map )); card->vcs[0 ] = vc; vc->class =SCHED_UBR0 ;
@@ -3695,13 +3690,12 @@ idt77252_init_one(struct pci_dev *pcidev goto err_out_disable_pdev; } - card =kmalloc (sizeof (struct idt77252_dev ),GFP_KERNEL ); + card =kzalloc (sizeof (struct idt77252_dev ),GFP_KERNEL );if (!card) {printk ("idt77252-%d: can't allocate private data\n" , index); err = -ENOMEM ; goto err_out_disable_pdev; } -memset (card,0 ,sizeof (struct idt77252_dev )); card->revision = revision; card->index = index;
drivers/atm/iphase.c renamed from drivers/atm/iphase.c.orig +2 -4
@@ -1601,14 +1601,13 @@ static int rx_init(struct atm_dev *dev)skb_queue_head_init (&iadev->rx_dma_q); iadev->rx_free_desc_qhead =NULL ; - iadev->rx_open =kmalloc (4 *iadev->num_vc,GFP_KERNEL ); + iadev->rx_open =kzalloc (4 *iadev->num_vc,GFP_KERNEL );if (!iadev->rx_open) { printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n", dev->number); goto err_free_dle; } -memset (iadev->rx_open,0 ,4 *iadev->num_vc); iadev->rxing =1 ; iadev->rx_pkt_cnt =0 ;/* Mode Register */
@@ -3174,12 +3173,11 @@ static int __devinit ia_init_one(structunsigned long flags;int ret; - iadev =kmalloc (sizeof (*iadev),GFP_KERNEL ); + iadev =kzalloc (sizeof (*iadev),GFP_KERNEL );if (!iadev) { ret = -ENOMEM ; goto err_out; } -memset (iadev,0 ,sizeof (*iadev)); iadev->pci = pdev; IF_INIT(printk("ia detected at bus:%d dev: %d function:%d\n",
drivers/atm/firestream.c renamed from drivers/atm/firestream.c.orig +3 -7
@@ -1782,7 +1782,7 @@ static int __devinit fs_init (struct fs_write_fs (dev,RAM , (1 << (28 -FS155_VPI_BITS -FS155_VCI_BITS )) -1 ); dev->nchannels =FS155_NR_CHANNELS ; } - dev->atm_vccs =kmalloc (dev->nchannels *sizeof (struct atm_vcc *), + dev->atm_vccs =kcalloc (dev->nchannels,sizeof (struct atm_vcc *),GFP_KERNEL );fs_dprintk (FS_DEBUG_ALLOC ,"Alloc atmvccs: %p(%Zd)\n" , dev->atm_vccs, dev->nchannels *sizeof (struct atm_vcc *));
@@ -1792,9 +1792,8 @@ static int __devinit fs_init (struct fs_/* XXX Clean up..... */ return 1 ; } -memset (dev->atm_vccs,0 , dev->nchannels *sizeof (struct atm_vcc *)); - dev->tx_inuse =kmalloc (dev->nchannels /8 /* bits/byte */ ,GFP_KERNEL ); + dev->tx_inuse =kzalloc (dev->nchannels /8 /* bits/byte */ ,GFP_KERNEL );fs_dprintk (FS_DEBUG_ALLOC ,"Alloc tx_inuse: %p(%d)\n" , dev->atm_vccs, dev->nchannels /8 );
@@ -1803,7 +1802,6 @@ static int __devinit fs_init (struct fs_/* XXX Clean up..... */ return 1 ; } -memset (dev->tx_inuse,0 , dev->nchannels /8 );/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */ /* -- RAS2 : FS50 only: Default is OK. */
@@ -1891,14 +1889,12 @@ static int __devinit firestream_init_oneif (pci_enable_device (pci_dev)) goto err_out; - fs_dev =kmalloc (sizeof (struct fs_dev ),GFP_KERNEL ); + fs_dev =kzalloc (sizeof (struct fs_dev ),GFP_KERNEL );fs_dprintk (FS_DEBUG_ALLOC ,"Alloc fs-dev: %p(%Zd)\n" , fs_dev,sizeof (struct fs_dev ));if (!fs_dev) goto err_out; -memset (fs_dev,0 ,sizeof (struct fs_dev )); - atm_dev =atm_dev_register ("fs" , &ops,-1 ,NULL );if (!atm_dev) goto err_out_free_fs_dev;
drivers/atm/zatm.c renamed from drivers/atm/zatm.c.orig +6 -6
@@ -604,9 +604,9 @@ static int start_rx(struct atm_dev *dev)DPRINTK ("start_rx\n" ); zatm_dev =ZATM_DEV (dev); size =sizeof (struct atm_vcc *)*zatm_dev->chans; - zatm_dev->rx_map = (struct atm_vcc **)kmalloc (size,GFP_KERNEL ); -if (!zatm_dev->rx_map)return -ENOMEM ; -memset (zatm_dev->rx_map,0 ,size); + zatm_dev->rx_map = (struct atm_vcc **)kzalloc (size,GFP_KERNEL ); +if (!zatm_dev->rx_map) +return -ENOMEM ;/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */ zpokel (zatm_dev,(1 << dev->ci_range.vci_bits)-1 ,uPD98401_VRR);/* prepare free buffer pools */
@@ -952,9 +952,9 @@ static int open_tx_first(struct atm_vccskb_queue_head_init (&zatm_vcc->tx_queue);init_waitqueue_head (&zatm_vcc->tx_wait);/* initialize ring */ - zatm_vcc->ring =kmalloc (RING_SIZE ,GFP_KERNEL ); -if (!zatm_vcc->ring)return -ENOMEM ; -memset (zatm_vcc->ring,0 ,RING_SIZE ); + zatm_vcc->ring =kzalloc (RING_SIZE ,GFP_KERNEL ); +if (!zatm_vcc->ring) +return -ENOMEM ; loop = zatm_vcc->ring+RING_ENTRIES *RING_WORDS ; loop[0 ] = uPD98401_TXPD_V; loop[1 ] = loop[2 ] =0 ;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [Patch] kzalloc() conversion in drivers/atm
In reply to Eric Sesterhenndrivers/atm/adummy.c static int __init adummy_init(void) · line 118
Quoted 9 lines · Eric Sesterhenn
drivers/atm/adummy.c renamed from drivers/atm/adummy.c.orig +1
-1@@ -114,14 +114,13 @@ static int __init adummy_init(void)printk (KERN_ERR "adummy: version %s\n" ,DRV_VERSION ); - adummy_dev = (struct adummy_dev *)kmalloc (sizeof (struct adummy_dev ), + adummy_dev = (struct adummy_dev *)kzalloc (sizeof (struct adummy_dev ),GFP_KERNEL );
Casting kmalloc/kzalloc return values is not necessary.
[...]
drivers/atm/he.c he_init_one(struct pci_dev *pci_dev, con · line 388
Quoted 9 lines
drivers/atm/he.c renamed from drivers/atm/he.c.orig +1
-1@@ -384,13 +384,12 @@ he_init_one(struct pci_dev *pci_dev, con }pci_set_drvdata (pci_dev, atm_dev); - he_dev = (struct he_dev *)kmalloc (sizeof (struct he_dev ), + he_dev = (struct he_dev *)kzalloc (sizeof (struct he_dev ),GFP_KERNEL );
Same here.
[...]
drivers/atm/idt77252.c alloc_scq(struct idt77252_dev *card, int · line 645
Quoted 8 lines
drivers/atm/idt77252.c renamed from drivers/atm/idt77252.c.orig +1
-1@@ -642,10 +642,9 @@ alloc_scq(struct idt77252_dev *card, int {struct scq_info *scq; - scq = (struct scq_info *)kmalloc (sizeof (struct scq_info ),GFP_KERNEL ); + scq = (struct scq_info *)kzalloc (sizeof (struct scq_info ),GFP_KERNEL );
Ditto
[...]
drivers/atm/zatm.c static int start_rx(struct atm_dev *dev) · line 607
Quoted 10 lines
drivers/atm/zatm.c renamed from drivers/atm/zatm.c.orig +1
-3@@ -604,9 +604,9 @@ static int start_rx(struct atm_dev *dev)DPRINTK ("start_rx\n" ); zatm_dev =ZATM_DEV (dev); size =sizeof (struct atm_vcc *)*zatm_dev->chans; - zatm_dev->rx_map = (struct atm_vcc **)kmalloc (size,GFP_KERNEL ); -if (!zatm_dev->rx_map)return -ENOMEM ; -memset (zatm_dev->rx_map,0 ,size); + zatm_dev->rx_map = (struct atm_vcc **)kzalloc (size,GFP_KERNEL );
Same here
Cheers, Tobias
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [Patch] kzalloc() conversion in drivers/atm
In reply to Eric SesterhennQuoted 5 lines · Tobias Klauser
Quoted 4 lines · Eric Sesterhenn
drivers/atm/adummy.c renamed from drivers/atm/adummy.c.orig +0
-0@@ -114,14 +114,13 @@ static int __init adummy_init(void)
Quoted 7 lines
drivers/atm/adummy.c static int __init adummy_init(void) · line 118
Quoted 5 lines
drivers/atm/adummy.c renamed from drivers/atm/adummy.c.orig +1
-1printk (KERN_ERR "adummy: version %s\n" ,DRV_VERSION ); - adummy_dev = (struct adummy_dev *)kmalloc (sizeof (struct adummy_dev ), + adummy_dev = (struct adummy_dev *)kzalloc (sizeof (struct adummy_dev ),GFP_KERNEL );Casting kmalloc/kzalloc return values is not necessary.
here is an updated patch. Also compile tested with allyesconfig
drivers/atm/adummy.c renamed from drivers/atm/adummy.c.orig +2 -4
@@ -114,14 +114,12 @@ static int __init adummy_init(void)printk (KERN_ERR "adummy: version %s\n" ,DRV_VERSION ); - adummy_dev = (struct adummy_dev *)kmalloc (sizeof (struct adummy_dev ), -GFP_KERNEL ); + adummy_dev =kzalloc (sizeof (struct adummy_dev ),GFP_KERNEL );if (!adummy_dev) { - printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n"); + printk(KERN_ERR DEV_LABEL ": kzalloc() failed\n"); err = -ENOMEM ; goto out; } -memset (adummy_dev,0 ,sizeof (struct adummy_dev )); atm_dev =atm_dev_register (DEV_LABEL , &adummy_ops,-1 ,NULL );if (!atm_dev) {
drivers/atm/he.c renamed from drivers/atm/he.c.orig +1 -3
@@ -384,13 +384,11 @@ he_init_one(struct pci_dev *pci_dev, con }pci_set_drvdata (pci_dev, atm_dev); - he_dev = (struct he_dev *)kmalloc (sizeof (struct he_dev ), -GFP_KERNEL ); + he_dev =kzalloc (sizeof (struct he_dev ),GFP_KERNEL );if (!he_dev) { err = -ENOMEM ; goto init_one_failure; } -memset (he_dev,0 ,sizeof (struct he_dev )); he_dev->pci_dev = pci_dev; he_dev->atm_dev = atm_dev;
drivers/atm/idt77252.c renamed from drivers/atm/idt77252.c.orig +6 -12
@@ -642,10 +642,9 @@ alloc_scq(struct idt77252_dev *card, int {struct scq_info *scq; - scq = (struct scq_info *)kmalloc (sizeof (struct scq_info ),GFP_KERNEL ); + scq =kzalloc (sizeof (struct scq_info ),GFP_KERNEL );if (!scq)return NULL ; -memset (scq,0 ,sizeof (struct scq_info )); scq->base =pci_alloc_consistent (card->pcidev,SCQ_SIZE , &scq->paddr);
@@ -2142,10 +2141,9 @@ idt77252_init_est(struct vc_map *vc, int {struct rate_estimator *est; - est =kmalloc (sizeof (struct rate_estimator ),GFP_KERNEL ); + est =kzalloc (sizeof (struct rate_estimator ),GFP_KERNEL );if (!est)return NULL ; -memset (est,0 ,sizeof (*est)); est->maxcps = pcr <0 ? -pcr : pcr; est->cps = est->maxcps;
@@ -2451,13 +2449,12 @@ idt77252_open(struct atm_vcc *vcc) index =VPCI2VC (card, vpi, vci);if (!card->vcs[index]) { - card->vcs[index] =kmalloc (sizeof (struct vc_map ),GFP_KERNEL ); + card->vcs[index] =kzalloc (sizeof (struct vc_map ),GFP_KERNEL );if (!card->vcs[index]) {printk ("%s: can't alloc vc in open()\n" , card->name);up (&card->mutex);return -ENOMEM ; } -memset (card->vcs[index],0 ,sizeof (struct vc_map )); card->vcs[index]->card = card; card->vcs[index]->index = index;
@@ -2926,12 +2923,11 @@ open_card_oam(struct idt77252_dev *card)for (vci =3 ; vci <5 ; vci++) { index =VPCI2VC (card, vpi, vci); - vc =kmalloc (sizeof (struct vc_map ),GFP_KERNEL ); + vc =kzalloc (sizeof (struct vc_map ),GFP_KERNEL );if (!vc) {printk ("%s: can't alloc vc\n" , card->name);return -ENOMEM ; } -memset (vc,0 ,sizeof (struct vc_map )); vc->index = index; card->vcs[index] = vc;
@@ -2995,12 +2991,11 @@ open_card_ubr0(struct idt77252_dev *card {struct vc_map *vc; - vc =kmalloc (sizeof (struct vc_map ),GFP_KERNEL ); + vc =kzalloc (sizeof (struct vc_map ),GFP_KERNEL );if (!vc) {printk ("%s: can't alloc vc\n" , card->name);return -ENOMEM ; } -memset (vc,0 ,sizeof (struct vc_map )); card->vcs[0 ] = vc; vc->class =SCHED_UBR0 ;
@@ -3695,13 +3690,12 @@ idt77252_init_one(struct pci_dev *pcidev goto err_out_disable_pdev; } - card =kmalloc (sizeof (struct idt77252_dev ),GFP_KERNEL ); + card =kzalloc (sizeof (struct idt77252_dev ),GFP_KERNEL );if (!card) {printk ("idt77252-%d: can't allocate private data\n" , index); err = -ENOMEM ; goto err_out_disable_pdev; } -memset (card,0 ,sizeof (struct idt77252_dev )); card->revision = revision; card->index = index;
drivers/atm/iphase.c renamed from drivers/atm/iphase.c.orig +2 -4
@@ -1601,14 +1601,13 @@ static int rx_init(struct atm_dev *dev)skb_queue_head_init (&iadev->rx_dma_q); iadev->rx_free_desc_qhead =NULL ; - iadev->rx_open =kmalloc (4 *iadev->num_vc,GFP_KERNEL ); + iadev->rx_open =kzalloc (4 *iadev->num_vc,GFP_KERNEL );if (!iadev->rx_open) { printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n", dev->number); goto err_free_dle; } -memset (iadev->rx_open,0 ,4 *iadev->num_vc); iadev->rxing =1 ; iadev->rx_pkt_cnt =0 ;/* Mode Register */
@@ -3174,12 +3173,11 @@ static int __devinit ia_init_one(structunsigned long flags;int ret; - iadev =kmalloc (sizeof (*iadev),GFP_KERNEL ); + iadev =kzalloc (sizeof (*iadev),GFP_KERNEL );if (!iadev) { ret = -ENOMEM ; goto err_out; } -memset (iadev,0 ,sizeof (*iadev)); iadev->pci = pdev; IF_INIT(printk("ia detected at bus:%d dev: %d function:%d\n",
drivers/atm/firestream.c renamed from drivers/atm/firestream.c.orig +3 -7
@@ -1782,7 +1782,7 @@ static int __devinit fs_init (struct fs_write_fs (dev,RAM , (1 << (28 -FS155_VPI_BITS -FS155_VCI_BITS )) -1 ); dev->nchannels =FS155_NR_CHANNELS ; } - dev->atm_vccs =kmalloc (dev->nchannels *sizeof (struct atm_vcc *), + dev->atm_vccs =kcalloc (dev->nchannels,sizeof (struct atm_vcc *),GFP_KERNEL );fs_dprintk (FS_DEBUG_ALLOC ,"Alloc atmvccs: %p(%Zd)\n" , dev->atm_vccs, dev->nchannels *sizeof (struct atm_vcc *));
@@ -1792,9 +1792,8 @@ static int __devinit fs_init (struct fs_/* XXX Clean up..... */ return 1 ; } -memset (dev->atm_vccs,0 , dev->nchannels *sizeof (struct atm_vcc *)); - dev->tx_inuse =kmalloc (dev->nchannels /8 /* bits/byte */ ,GFP_KERNEL ); + dev->tx_inuse =kzalloc (dev->nchannels /8 /* bits/byte */ ,GFP_KERNEL );fs_dprintk (FS_DEBUG_ALLOC ,"Alloc tx_inuse: %p(%d)\n" , dev->atm_vccs, dev->nchannels /8 );
@@ -1803,7 +1802,6 @@ static int __devinit fs_init (struct fs_/* XXX Clean up..... */ return 1 ; } -memset (dev->tx_inuse,0 , dev->nchannels /8 );/* -- RAS1 : FS155 and 50 differ. Default (0) should be OK for both */ /* -- RAS2 : FS50 only: Default is OK. */
@@ -1891,14 +1889,12 @@ static int __devinit firestream_init_oneif (pci_enable_device (pci_dev)) goto err_out; - fs_dev =kmalloc (sizeof (struct fs_dev ),GFP_KERNEL ); + fs_dev =kzalloc (sizeof (struct fs_dev ),GFP_KERNEL );fs_dprintk (FS_DEBUG_ALLOC ,"Alloc fs-dev: %p(%Zd)\n" , fs_dev,sizeof (struct fs_dev ));if (!fs_dev) goto err_out; -memset (fs_dev,0 ,sizeof (struct fs_dev )); - atm_dev =atm_dev_register ("fs" , &ops,-1 ,NULL );if (!atm_dev) goto err_out_free_fs_dev;
drivers/atm/zatm.c renamed from drivers/atm/zatm.c.orig +6 -6
@@ -604,9 +604,9 @@ static int start_rx(struct atm_dev *dev)DPRINTK ("start_rx\n" ); zatm_dev =ZATM_DEV (dev); size =sizeof (struct atm_vcc *)*zatm_dev->chans; - zatm_dev->rx_map = (struct atm_vcc **)kmalloc (size,GFP_KERNEL ); -if (!zatm_dev->rx_map)return -ENOMEM ; -memset (zatm_dev->rx_map,0 ,size); + zatm_dev->rx_map = (struct atm_vcc **)kzalloc (size,GFP_KERNEL ); +if (!zatm_dev->rx_map) +return -ENOMEM ;/* set VPI/VCI split (use all VCIs and give what's left to VPIs) */ zpokel (zatm_dev,(1 << dev->ci_range.vci_bits)-1 ,uPD98401_VRR);/* prepare free buffer pools */
@@ -952,9 +952,9 @@ static int open_tx_first(struct atm_vccskb_queue_head_init (&zatm_vcc->tx_queue);init_waitqueue_head (&zatm_vcc->tx_wait);/* initialize ring */ - zatm_vcc->ring =kmalloc (RING_SIZE ,GFP_KERNEL ); -if (!zatm_vcc->ring)return -ENOMEM ; -memset (zatm_vcc->ring,0 ,RING_SIZE ); + zatm_vcc->ring =kzalloc (RING_SIZE ,GFP_KERNEL ); +if (!zatm_vcc->ring) +return -ENOMEM ; loop = zatm_vcc->ring+RING_ENTRIES *RING_WORDS ; loop[0 ] = uPD98401_TXPD_V; loop[1 ] = loop[2 ] =0 ;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/usb
In reply to Eric Sesterhennhi,
this patch converts drivers/usb to kzalloc usage.
Compile tested with allyes config.
This also fixes a bug in drivers/usb/serial/cp2101.c where memset() was used before checking if kmalloc() returns NULL.
I think there also was a bug in drivers/usb/gadget/inode.c because it used sizeof(*data) for the kmalloc() and sizeof(data) for the memset(), since sizeof(data) just returns the size for a pointer.
I assume there is also a bug in drivers/usb/gadget/omap_udc.c in omap_alloc_request(), req gets allocated via kmalloc() and the function returns &req->req, no matter if req is NULL, which looks like a NULL dereference to me, maybe someone who is more familar with this code might have a look at it.
drivers/usb/net/zd1201.c renamed from drivers/usb/net/zd1201.c.orig +3 -6
@@ -621,10 +621,9 @@ static int zd1201_drvr_start(struct zd12__le16 zdmax;unsigned char *buffer; - buffer =kmalloc (ZD1201_RXSIZE ,GFP_KERNEL ); + buffer =kzalloc (ZD1201_RXSIZE ,GFP_KERNEL );if (!buffer)return -ENOMEM ; -memset (buffer,0 ,ZD1201_RXSIZE ); usb_fill_bulk_urb(zd->rx_urb, zd->usb, usb_rcvbulkpipe(zd->usb, zd->endp_in), buffer, ZD1201_RXSIZE,
@@ -1750,11 +1749,9 @@ static int zd1201_probe(struct usb_inter usb =interface_to_usbdev (interface); - zd =kmalloc (sizeof (struct zd1201 ),GFP_KERNEL ); -if (!zd) { + zd =kzalloc (sizeof (struct zd1201 ),GFP_KERNEL ); +if (!zd)return -ENOMEM ; - } -memset (zd,0 ,sizeof (struct zd1201 )); zd->ap = ap; zd->usb = usb; zd->removed =0 ;
drivers/usb/class/usb-midi.c renamed from drivers/usb/class/usb-midi.c.orig +3 -6
@@ -995,12 +995,11 @@ static struct midi_in_endpoint *alloc_mi bufSize =usb_maxpacket ( d, pipe,0 );/* usb_pipein() = ! usb_pipeout() = true for an in Endpoint */ - ep = (struct midi_in_endpoint *)kmalloc (sizeof (struct midi_in_endpoint ),GFP_KERNEL ); + ep =kzalloc (sizeof (struct midi_in_endpoint ),GFP_KERNEL );if ( !ep ) {printk (KERN_ERR "usbmidi: no memory for midi in-endpoint\n" );return NULL ; } -memset ( ep,0 ,sizeof (struct midi_in_endpoint ) );// this sets cables[] and readers to 0, too. // for (i=0; i<16; i++) ep->cables[i] = 0; // discard cable // ep->readers = 0;
@@ -1065,12 +1064,11 @@ static struct midi_out_endpoint *alloc_m pipe =usb_sndbulkpipe ( d, endPoint ); bufSize =usb_maxpacket ( d, pipe,1 ); - ep = (struct midi_out_endpoint *)kmalloc (sizeof (struct midi_out_endpoint ),GFP_KERNEL ); + ep =kzalloc (sizeof (struct midi_out_endpoint ),GFP_KERNEL );if ( !ep ) {printk (KERN_ERR "usbmidi: no memory for midi out-endpoint\n" );return NULL ; } -memset ( ep,0 ,sizeof (struct midi_out_endpoint ) ); ep->endpoint = endPoint; ep->buf = (unsigned char *)kmalloc (sizeof (unsigned char )*bufSize,GFP_KERNEL );
@@ -1958,11 +1956,10 @@ static int usb_midi_probe(struct usb_intstruct usb_device *dev =interface_to_usbdev (intf);int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; - s = (struct usb_midi_state *)kmalloc (sizeof (struct usb_midi_state ),GFP_KERNEL ); + s =kzalloc (sizeof (struct usb_midi_state ),GFP_KERNEL );if ( !s )return -ENOMEM ; -memset ( s,0 ,sizeof (struct usb_midi_state ) );INIT_LIST_HEAD (&s->midiDevList);INIT_LIST_HEAD (&s->inEndpointList);INIT_LIST_HEAD (&s->outEndpointList);
drivers/usb/class/audio.c renamed from drivers/usb/class/audio.c.orig +2 -4
@@ -2804,9 +2804,8 @@ static void usb_audio_parsestreaming(strunsigned char *fmt, *csep;unsigned int i, j, k, format, idx; -if (!(as =kmalloc (sizeof (struct usb_audiodev ),GFP_KERNEL ))) +if (!(as =kzalloc (sizeof (struct usb_audiodev ),GFP_KERNEL )))return ; -memset (as,0 ,sizeof (struct usb_audiodev ));init_waitqueue_head (&as->usbin.dma.wait);init_waitqueue_head (&as->usbout.dma.wait);spin_lock_init (&as->lock);
@@ -3646,9 +3645,8 @@ static struct usb_audio_state *usb_audiounsigned char *p1;unsigned int i, j, k, numifin =0 , numifout =0 ; -if (!(s =kmalloc (sizeof (struct usb_audio_state ),GFP_KERNEL ))) +if (!(s =kzalloc (sizeof (struct usb_audio_state ),GFP_KERNEL )))return NULL ; -memset (s,0 ,sizeof (struct usb_audio_state ));INIT_LIST_HEAD (&s->audiolist);INIT_LIST_HEAD (&s->mixerlist); s->usbdev = dev;
drivers/usb/media/pwc/pwc-if.c renamed from drivers/usb/media/pwc/pwc-if.c.orig +1 -2
@@ -1871,12 +1871,11 @@ static int usb_pwc_probe(struct usb_inteInfo ("Warning: more than 1 configuration available.\n" );/* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */ - pdev =kmalloc (sizeof (struct pwc_device ),GFP_KERNEL ); + pdev =kzalloc (sizeof (struct pwc_device ),GFP_KERNEL );if (pdev ==NULL ) {Err ("Oops, could not allocate memory for pwc_device.\n" );return -ENOMEM ; } -memset (pdev,0 ,sizeof (struct pwc_device )); pdev->type = type_id; pdev->vsize = default_size; pdev->vframes = default_fps;
drivers/usb/media/w9968cf.c renamed from drivers/usb/media/w9968cf.c.orig +2 -4
@@ -3532,21 +3532,19 @@ w9968cf_usb_probe(struct usb_interface*/* Allocate 2 bytes of memory for camera control USB transfers */ -if (!(cam->control_buffer =kmalloc (2 ,GFP_KERNEL ))) { +if (!(cam->control_buffer =kzalloc (2 ,GFP_KERNEL ))) {DBG (1 ,"Couldn't allocate memory for camera control transfers" ) err = -ENOMEM; goto fail; } -memset (cam->control_buffer,0 ,2 );/* Allocate 8 bytes of memory for USB data transfers to the FSB */ -if (!(cam->data_buffer =kmalloc (8 ,GFP_KERNEL ))) { +if (!(cam->data_buffer =kzalloc (8 ,GFP_KERNEL ))) {DBG (1 ,"Couldn't allocate memory for data " "transfers to the FSB" ) err = -ENOMEM; goto fail; } -memset (cam->data_buffer,0 ,8 );/* Register the V4L device */ cam->v4ldev =video_device_alloc ();
drivers/usb/media/dabusb.c renamed from drivers/usb/media/dabusb.c.orig +1 -2
@@ -217,12 +217,11 @@ static int dabusb_alloc_buffers (pdabusb pipesize, packets, transfer_buffer_length);while (buffers < (s->total_buffer_size <<10 )) { - b = (pbuff_t )kmalloc (sizeof (buff_t),GFP_KERNEL ); + b =kzalloc (sizeof (buff_t),GFP_KERNEL );if (!b) {err ("kmalloc(sizeof(buff_t))==NULL" ); goto err; } -memset (b,0 ,sizeof (buff_t)); b->s = s; b->purb =usb_alloc_urb (packets,GFP_KERNEL );if (!b->purb) {
drivers/usb/media/se401.c renamed from drivers/usb/media/se401.c.orig +1 -3
@@ -1345,13 +1345,11 @@ static int se401_probe(struct usb_interf/* We found one */ info ("SE401 camera found: %s" , camera_name); -if ((se401 =kmalloc (sizeof (*se401),GFP_KERNEL )) ==NULL ) { +if ((se401 =kzalloc (sizeof (*se401),GFP_KERNEL )) ==NULL ) {err ("couldn't kmalloc se401 struct" );return -ENOMEM ; } -memset (se401,0 ,sizeof (*se401)); - se401->dev = dev; se401->iface = interface->bInterfaceNumber; se401->camera_name = camera_name;
drivers/usb/media/ov511.c renamed from drivers/usb/media/ov511.c.orig +1 -3
@@ -5686,13 +5686,11 @@ ov51x_probe(struct usb_interface *intf,if (idesc->bInterfaceSubClass !=0x00 )return -ENODEV ; -if ((ov =kmalloc (sizeof (*ov),GFP_KERNEL )) ==NULL ) { +if ((ov =kzalloc (sizeof (*ov),GFP_KERNEL )) ==NULL ) {err ("couldn't kmalloc ov struct" ); goto error_out; } -memset (ov,0 ,sizeof (*ov)); - ov->dev = dev; ov->iface = idesc->bInterfaceNumber; ov->led_policy = led;
drivers/usb/media/stv680.c renamed from drivers/usb/media/stv680.c.orig +2 -5
@@ -317,12 +317,11 @@ static int stv_init (struct usb_stv *stvunsigned char *buffer;unsigned long int bufsize; - buffer =kmalloc (40 ,GFP_KERNEL ); + buffer =kzalloc (40 ,GFP_KERNEL );if (buffer ==NULL ) {PDEBUG (0 ,"STV(e): Out of (small buf) memory" );return -1 ; } -memset (buffer,0 ,40 );udelay (100 );/* set config 1, interface 0, alternate 0 */
@@ -1387,14 +1386,12 @@ static int stv680_probe (struct usb_inte goto error; }/* We found one */ -if ((stv680 =kmalloc (sizeof (*stv680),GFP_KERNEL )) ==NULL ) { +if ((stv680 =kzalloc (sizeof (*stv680),GFP_KERNEL )) ==NULL ) {PDEBUG (0 ,"STV(e): couldn't kmalloc stv680 struct." ); retval = -ENOMEM ; goto error; } -memset (stv680,0 ,sizeof (*stv680)); - stv680->udev = dev; stv680->camera_name = camera_name;
drivers/usb/image/mdc800.c renamed from drivers/usb/image/mdc800.c.orig +1 -2
@@ -978,11 +978,10 @@ static int __init usb_mdc800_init (void) {int retval = -ENODEV ;/* Allocate Memory */ - mdc800=kmalloc (sizeof (struct mdc800_data ),GFP_KERNEL ); + mdc800 =kzalloc (sizeof (struct mdc800_data ),GFP_KERNEL );if (!mdc800) goto cleanup_on_fail; -memset (mdc800,0 ,sizeof (struct mdc800_data )); mdc800->dev =NULL ; mdc800->open=0 ; mdc800->state=NOT_CONNECTED ;
drivers/usb/serial/visor.c renamed from drivers/usb/serial/visor.c.orig +1 -2
@@ -760,10 +760,9 @@ static int generic_startup(struct usb_seint i;for (i =0 ; i < serial->num_ports; ++i) { - priv =kmalloc (sizeof (*priv),GFP_KERNEL ); + priv =kzalloc (sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ; -memset (priv,0x00 ,sizeof (*priv));spin_lock_init (&priv->lock);usb_set_serial_port_data (serial->port[i], priv); }
drivers/usb/serial/io_ti.c renamed from drivers/usb/serial/io_ti.c.orig +2 -4
@@ -2727,12 +2727,11 @@ static int edge_startup (struct usb_seri dev = serial->dev;/* create our private serial structure */ - edge_serial =kmalloc (sizeof (struct edgeport_serial ),GFP_KERNEL ); + edge_serial =kzalloc (sizeof (struct edgeport_serial ),GFP_KERNEL );if (edge_serial ==NULL ) {dev_err (&serial->dev->dev,"%s - Out of memory\n" , __FUNCTION__);return -ENOMEM ; } -memset (edge_serial,0 ,sizeof (struct edgeport_serial ));sema_init (&edge_serial->es_sem,1 ); edge_serial->serial = serial;usb_set_serial_data (serial, edge_serial);
@@ -2745,12 +2744,11 @@ static int edge_startup (struct usb_seri/* set up our port private structures */ for (i =0 ; i < serial->num_ports; ++i) { - edge_port =kmalloc (sizeof (struct edgeport_port ),GFP_KERNEL ); + edge_port =kzalloc (sizeof (struct edgeport_port ),GFP_KERNEL );if (edge_port ==NULL ) {dev_err (&serial->dev->dev,"%s - Out of memory\n" , __FUNCTION__); goto cleanup; } -memset (edge_port,0 ,sizeof (struct edgeport_port ));spin_lock_init (&edge_port->ep_lock); edge_port->ep_out_buf =edge_buf_alloc (EDGE_OUT_BUF_SIZE );if (edge_port->ep_out_buf ==NULL ) {
drivers/usb/serial/option.c renamed from drivers/usb/serial/option.c.orig +1 -2
@@ -631,13 +631,12 @@ static int option_startup(struct usb_ser/* Now setup per port private data */ for (i =0 ; i < serial->num_ports; i++) { port = serial->port[i]; - portdata =kmalloc (sizeof (*portdata),GFP_KERNEL ); + portdata =kzalloc (sizeof (*portdata),GFP_KERNEL );if (!portdata) {dbg ("%s: kmalloc for option_port_private (%d) failed!." , __FUNCTION__, i);return (1 ); } -memset (portdata,0 ,sizeof (struct option_port_private ));usb_set_serial_port_data (port, portdata);
drivers/usb/serial/cp2101.c renamed from drivers/usb/serial/cp2101.c.orig +1 -3
@@ -169,9 +169,7 @@ static int cp2101_get_config(struct usb_/* Number of integers required to contain the array */ length = (((size -1 ) |3 ) +1 )/4 ; - buf =kmalloc (length *sizeof (u32),GFP_KERNEL ); -memset (buf,0 , length *sizeof (u32)); - + buf =kcalloc (length,sizeof (u32),GFP_KERNEL );if (!buf) {dev_err (&port->dev,"%s - out of memory.\n" , __FUNCTION__);return -ENOMEM ;
drivers/usb/serial/ti_usb_3410_5052.c renamed from drivers/usb/serial/ti_usb_3410_5052.c.orig +1 -2
@@ -416,12 +416,11 @@ static int ti_startup(struct usb_serial dev->actconfig->desc.bConfigurationValue);/* create device structure */ - tdev =kmalloc (sizeof (struct ti_device ),GFP_KERNEL ); + tdev =kzalloc (sizeof (struct ti_device ),GFP_KERNEL );if (tdev ==NULL ) {dev_err (&dev->dev,"%s - out of memory\n" , __FUNCTION__);return -ENOMEM ; } -memset (tdev,0 ,sizeof (struct ti_device ));sema_init (&tdev->td_open_close_sem,1 ); tdev->td_serial = serial;usb_set_serial_data (serial, tdev);
drivers/usb/serial/kobil_sct.c renamed from drivers/usb/serial/kobil_sct.c.orig +5 -11
@@ -255,11 +255,9 @@ static int kobil_open (struct usb_serial }// allocate memory for transfer buffer - transfer_buffer = (unsigned char *)kmalloc (transfer_buffer_length,GFP_KERNEL ); + transfer_buffer =kzalloc (transfer_buffer_length,GFP_KERNEL );if (! transfer_buffer) {return -ENOMEM ; - }else { -memset (transfer_buffer,0 , transfer_buffer_length); }// allocate write_urb
@@ -383,11 +381,10 @@ static void kobil_read_int_callback( str// BEGIN DEBUG /* -dbg_data = (unsigned char *) kmalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); +dbg_data = kzalloc((3 * purb->actual_length + 10) * sizeof(char), GFP_KERNEL); if (! dbg_data) { return; } -memset(dbg_data, 0, (3 * purb->actual_length + 10)); for (i = 0; i < purb->actual_length; i++) { sprintf(dbg_data +3*i, "%02X ", data[i]); }
@@ -518,11 +515,10 @@ static int kobil_tiocmget(struct usb_ser }// allocate memory for transfer buffer - transfer_buffer = (unsigned char *)kmalloc (transfer_buffer_length,GFP_KERNEL ); + transfer_buffer =kzalloc (transfer_buffer_length,GFP_KERNEL );if (!transfer_buffer) {return -ENOMEM ; } -memset (transfer_buffer,0 , transfer_buffer_length); result = usb_control_msg( port->serial->dev, usb_rcvctrlpipe(port->serial->dev, 0 ),
@@ -564,11 +560,10 @@ static int kobil_tiocmset(struct usb_se }// allocate memory for transfer buffer - transfer_buffer = (unsigned char *)kmalloc (transfer_buffer_length,GFP_KERNEL ); + transfer_buffer =kzalloc (transfer_buffer_length,GFP_KERNEL );if (! transfer_buffer) {return -ENOMEM ; } -memset (transfer_buffer,0 , transfer_buffer_length);if (set &TIOCM_RTS ) rts =1 ;
@@ -655,11 +650,10 @@ static int kobil_ioctl(struct usb_seria (struct termios __user *)arg))return -EFAULT ; - settings = (unsigned char *)kmalloc (50 ,GFP_KERNEL ); + settings =kzalloc (50 ,GFP_KERNEL );if (! settings) {return -ENOBUFS ; } -memset (settings,0 ,50 );switch (priv->internal_termios.c_cflag &CBAUD ) {case B1200 :
drivers/usb/serial/pl2303.c renamed from drivers/usb/serial/pl2303.c.orig +2 -4
@@ -218,10 +218,9 @@ static int pl2303_startup (struct usb_sedbg ("device type: %d" , type);for (i =0 ; i < serial->num_ports; ++i) { - priv =kmalloc (sizeof (struct pl2303_private ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct pl2303_private ),GFP_KERNEL );if (!priv) goto cleanup; -memset (priv,0x00 ,sizeof (struct pl2303_private ));spin_lock_init (&priv->lock); priv->buf =pl2303_buf_alloc (PL2303_BUF_SIZE );if (priv->buf ==NULL ) {
@@ -383,12 +382,11 @@ static void pl2303_set_termios (struct u } } - buf =kmalloc (7 ,GFP_KERNEL ); + buf =kzalloc (7 ,GFP_KERNEL );if (!buf) {dev_err (&port->dev,"%s - out of memory.\n" , __FUNCTION__);return ; } -memset (buf,0x00 ,0x07 ); i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0), GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
drivers/usb/serial/keyspan.c renamed from drivers/usb/serial/keyspan.c.orig +2 -4
@@ -2250,12 +2250,11 @@ static int keyspan_startup (struct usb_s }/* Setup private data for serial driver */ - s_priv =kmalloc (sizeof (struct keyspan_serial_private ),GFP_KERNEL ); + s_priv =kzalloc (sizeof (struct keyspan_serial_private ),GFP_KERNEL );if (!s_priv) {dbg ("%s - kmalloc for keyspan_serial_private failed." , __FUNCTION__);return -ENOMEM ; } -memset (s_priv,0 ,sizeof (struct keyspan_serial_private )); s_priv->device_details = d_details;usb_set_serial_data (serial, s_priv);
@@ -2263,12 +2262,11 @@ static int keyspan_startup (struct usb_s/* Now setup per port private data */ for (i =0 ; i < serial->num_ports; i++) { port = serial->port[i]; - p_priv =kmalloc (sizeof (struct keyspan_port_private ),GFP_KERNEL ); + p_priv =kzalloc (sizeof (struct keyspan_port_private ),GFP_KERNEL );if (!p_priv) {dbg ("%s - kmalloc for keyspan_port_private (%d) failed!." , __FUNCTION__, i);return (1 ); } -memset (p_priv,0 ,sizeof (struct keyspan_port_private )); p_priv->device_details = d_details;usb_set_serial_port_data (port, p_priv); }
drivers/usb/serial/io_edgeport.c renamed from drivers/usb/serial/io_edgeport.c.orig +1 -2
@@ -2725,12 +2725,11 @@ static int edge_startup (struct usb_seri dev = serial->dev;/* create our private serial structure */ - edge_serial =kmalloc (sizeof (struct edgeport_serial ),GFP_KERNEL ); + edge_serial =kzalloc (sizeof (struct edgeport_serial ),GFP_KERNEL );if (edge_serial ==NULL ) {dev_err (&serial->dev->dev,"%s - Out of memory\n" , __FUNCTION__);return -ENOMEM ; } -memset (edge_serial,0 ,sizeof (struct edgeport_serial ));spin_lock_init (&edge_serial->es_lock); edge_serial->serial = serial;usb_set_serial_data (serial, edge_serial);
drivers/usb/serial/usb-serial.c renamed from drivers/usb/serial/usb-serial.c.orig +2 -4
@@ -564,12 +564,11 @@ static struct usb_serial * create_serial {struct usb_serial *serial; - serial =kmalloc (sizeof (*serial),GFP_KERNEL ); + serial =kzalloc (sizeof (*serial),GFP_KERNEL );if (!serial) {dev_err (&dev->dev,"%s - out of memory\n" , __FUNCTION__);return NULL ; } -memset (serial,0 ,sizeof (*serial)); serial->dev =usb_get_dev (dev); serial->type = driver; serial->interface = interface;
@@ -778,10 +777,9 @@ int usb_serial_probe(struct usb_interfac serial->num_port_pointers = max_endpoints;dbg ("%s - setting up %d port structures for this device" , __FUNCTION__, max_endpoints);for (i =0 ; i < max_endpoints; ++i) { - port =kmalloc (sizeof (struct usb_serial_port ),GFP_KERNEL ); + port =kzalloc (sizeof (struct usb_serial_port ),GFP_KERNEL );if (!port) goto probe_error; -memset (port,0x00 ,sizeof (struct usb_serial_port )); port->number = i + serial->minor; port->serial = serial;spin_lock_init (&port->lock);
drivers/usb/serial/cypress_m8.c renamed from drivers/usb/serial/cypress_m8.c.orig +1 -2
@@ -435,11 +435,10 @@ static int generic_startup (struct usb_sdbg ("%s - port %d" , __FUNCTION__, serial->port[0 ]->number); - priv =kmalloc (sizeof (struct cypress_private ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct cypress_private ),GFP_KERNEL );if (!priv)return -ENOMEM ; -memset (priv,0x00 ,sizeof (struct cypress_private ));spin_lock_init (&priv->lock); priv->buf =cypress_buf_alloc (CYPRESS_BUF_SIZE );if (priv->buf ==NULL ) {
drivers/usb/serial/ftdi_sio.c renamed from drivers/usb/serial/ftdi_sio.c.orig +1 -2
@@ -1135,12 +1135,11 @@ static int ftdi_sio_attach (struct usb_sdbg ("%s" ,__FUNCTION__); - priv =kmalloc (sizeof (struct ftdi_private ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct ftdi_private ),GFP_KERNEL );if (!priv){err ("%s- kmalloc(%Zd) failed." , __FUNCTION__,sizeof (struct ftdi_private ));return -ENOMEM ; } -memset (priv,0 ,sizeof (*priv));spin_lock_init (&priv->rx_lock);init_waitqueue_head (&priv->delta_msr_wait);
drivers/usb/serial/mct_u232.c renamed from drivers/usb/serial/mct_u232.c.orig +1 -2
@@ -348,10 +348,9 @@ static int mct_u232_startup (struct usb_struct mct_u232_private *priv;struct usb_serial_port *port, *rport; - priv =kmalloc (sizeof (struct mct_u232_private ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct mct_u232_private ),GFP_KERNEL );if (!priv)return -ENOMEM ; -memset (priv,0 ,sizeof (struct mct_u232_private ));spin_lock_init (&priv->lock);usb_set_serial_port_data (serial->port[0 ], priv);
drivers/usb/serial/garmin_gps.c renamed from drivers/usb/serial/garmin_gps.c.orig +1 -2
@@ -1422,12 +1422,11 @@ static int garmin_attach (struct usb_serdbg ("%s" , __FUNCTION__); - garmin_data_p =kmalloc (sizeof (struct garmin_data ),GFP_KERNEL ); + garmin_data_p =kzalloc (sizeof (struct garmin_data ),GFP_KERNEL );if (garmin_data_p ==NULL ) {dev_err (&port->dev,"%s - Out of memory\n" , __FUNCTION__);return -ENOMEM ; } -memset (garmin_data_p,0 ,sizeof (struct garmin_data ));init_timer (&garmin_data_p->timer);spin_lock_init (&garmin_data_p->lock);INIT_LIST_HEAD (&garmin_data_p->pktlist);
drivers/usb/serial/ir-usb.c renamed from drivers/usb/serial/ir-usb.c.orig +1 -2
@@ -184,10 +184,9 @@ static struct irda_class_desc *irda_usb_struct irda_class_desc *desc;int ret; - desc =kmalloc (sizeof (struct irda_class_desc ),GFP_KERNEL ); + desc =kzalloc (sizeof (struct irda_class_desc ),GFP_KERNEL );if (desc ==NULL )return NULL ; -memset (desc,0 ,sizeof (struct irda_class_desc )); ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0), IU_REQ_GET_CLASS_DESC,
drivers/usb/host/hc_crisv10.c renamed from drivers/usb/host/hc_crisv10.c.orig +4 -8
@@ -2137,10 +2137,9 @@ static int etrax_usb_submit_bulk_urb(str urb->status = -EINPROGRESS ;/* Setup the hcpriv data. */ - urb_priv =kmalloc (sizeof (etrax_urb_priv_t),KMALLOC_FLAG ); + urb_priv =kzalloc (sizeof (etrax_urb_priv_t),KMALLOC_FLAG );assert (urb_priv !=NULL );/* This sets rx_offset to 0. */ -memset (urb_priv,0 ,sizeof (etrax_urb_priv_t)); urb_priv->urb_state =NOT_STARTED ; urb->hcpriv = urb_priv;
@@ -2475,10 +2474,9 @@ static int etrax_usb_submit_ctrl_urb(str urb->status = -EINPROGRESS ;/* Setup the hcpriv data. */ - urb_priv =kmalloc (sizeof (etrax_urb_priv_t),KMALLOC_FLAG ); + urb_priv =kzalloc (sizeof (etrax_urb_priv_t),KMALLOC_FLAG );assert (urb_priv !=NULL );/* This sets rx_offset to 0. */ -memset (urb_priv,0 ,sizeof (etrax_urb_priv_t)); urb_priv->urb_state =NOT_STARTED ; urb->hcpriv = urb_priv;
@@ -2767,9 +2765,8 @@ static void etrax_usb_add_to_intr_sb_lis maxlen =usb_maxpacket (urb->dev, urb->pipe,usb_pipeout (urb->pipe)); interval = urb->interval; - urb_priv =kmalloc (sizeof (etrax_urb_priv_t),KMALLOC_FLAG ); + urb_priv =kzalloc (sizeof (etrax_urb_priv_t),KMALLOC_FLAG );assert (urb_priv !=NULL ); -memset (urb_priv,0 ,sizeof (etrax_urb_priv_t)); urb->hcpriv = urb_priv; first_ep = &TxIntrEPList[0 ];
@@ -2997,9 +2994,8 @@ static void etrax_usb_add_to_isoc_sb_lis prev_sb_desc = next_sb_desc = temp_sb_desc =NULL ; - urb_priv =kmalloc (sizeof (etrax_urb_priv_t),GFP_ATOMIC ); + urb_priv =kzalloc (sizeof (etrax_urb_priv_t),GFP_ATOMIC );assert (urb_priv !=NULL ); -memset (urb_priv,0 ,sizeof (etrax_urb_priv_t)); urb->hcpriv = urb_priv; urb_priv->epid = epid;
drivers/usb/host/sl811_cs.c renamed from drivers/usb/host/sl811_cs.c.orig +1 -2
@@ -330,10 +330,9 @@ static int sl811_cs_attach(struct pcmcialocal_info_t *local;dev_link_t *link; - 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)); link = &local->link; link->priv = local;
drivers/usb/host/ehci-sched.c renamed from drivers/usb/host/ehci-sched.c.orig +1 -2
@@ -863,9 +863,8 @@ iso_sched_alloc (unsigned packets, gfp_tint size =sizeof *iso_sched; size += packets *sizeof (struct ehci_iso_packet ); - iso_sched =kmalloc (size, mem_flags); + iso_sched =kzalloc (size, mem_flags);if (likely (iso_sched !=NULL )) { -memset (iso_sched,0 , size);INIT_LIST_HEAD (&iso_sched->td_list); }return iso_sched;
drivers/usb/host/ehci-mem.c renamed from drivers/usb/host/ehci-mem.c.orig +3 -7
@@ -221,13 +221,9 @@ static int ehci_mem_init (struct ehci_hc ehci->periodic [i] =EHCI_LIST_END ;/* software shadow of hardware table */ - ehci->pshadow =kmalloc (ehci->periodic_size *sizeof (void *), flags); -if (ehci->pshadow ==NULL ) { - goto fail; - } -memset (ehci->pshadow,0 , ehci->periodic_size *sizeof (void *)); - -return 0 ; + ehci->pshadow =kcalloc (ehci->periodic_size,sizeof (void *), flags); +if (ehci->pshadow !=NULL ) +return 0 ; fail:ehci_dbg (ehci,"couldn't init memory\n" );
drivers/usb/storage/jumpshot.c renamed from drivers/usb/storage/jumpshot.c.orig +1 -2
@@ -441,12 +441,11 @@ int jumpshot_transport(struct scsi_cmnd };if (!us->extra) { - us->extra =kmalloc (sizeof (struct jumpshot_info ),GFP_NOIO ); + us->extra =kzalloc (sizeof (struct jumpshot_info ),GFP_NOIO );if (!us->extra) {US_DEBUGP ("jumpshot_transport: Gah! Can't allocate storage for jumpshot info struct!\n" );return USB_STOR_TRANSPORT_ERROR ; } -memset (us->extra,0 ,sizeof (struct jumpshot_info )); us->extra_destructor = jumpshot_info_destructor; }
drivers/usb/storage/shuttle_usbat.c renamed from drivers/usb/storage/shuttle_usbat.c.orig +1 -2
@@ -1318,12 +1318,11 @@ int init_usbat(struct us_data *us)unsigned char subcountL =USBAT_ATA_LBA_ME ;unsigned char *status = us->iobuf; - us->extra =kmalloc (sizeof (struct usbat_info ),GFP_NOIO ); + us->extra =kzalloc (sizeof (struct usbat_info ),GFP_NOIO );if (!us->extra) {US_DEBUGP ("init_usbat: Gah! Can't allocate storage for usbat info struct!\n" );return 1 ; } -memset (us->extra,0 ,sizeof (struct usbat_info )); info = (struct usbat_info *) (us->extra);/* Enable peripheral control signals */
drivers/usb/storage/isd200.c renamed from drivers/usb/storage/isd200.c.orig +6 -10
@@ -1360,22 +1360,18 @@ static int isd200_init_info(struct us_daint retStatus =ISD200_GOOD ;struct isd200_info *info; - info = (struct isd200_info *) -kmalloc (sizeof (struct isd200_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct isd200_info ),GFP_KERNEL ); +if (!info) retStatus =ISD200_ERROR ;else { -memset (info,0 ,sizeof (struct isd200_info )); - info->id = (struct hd_driveid *) -kmalloc (sizeof (struct hd_driveid ),GFP_KERNEL ); - info->RegsBuf = (unsigned char *) -kmalloc (sizeof (info->ATARegs),GFP_KERNEL ); + info->id =kzalloc (sizeof (struct hd_driveid ),GFP_KERNEL ); + info->RegsBuf =kmalloc (sizeof (info->ATARegs),GFP_KERNEL );if (!info->id || !info->RegsBuf) {isd200_free_info_ptrs (info);kfree (info); retStatus =ISD200_ERROR ; - }else -memset (info->id,0 ,sizeof (struct hd_driveid )); + } }if (retStatus ==ISD200_GOOD ) {
@@ -1384,7 +1380,7 @@ static int isd200_init_info(struct us_da }else US_DEBUGP ("ERROR - kmalloc failure\n" ); -return (retStatus); +return retStatus; }/**************************************************************************
drivers/usb/storage/sddr55.c renamed from drivers/usb/storage/sddr55.c.orig +1 -2
@@ -751,11 +751,10 @@ int sddr55_transport(struct scsi_cmnd *sstruct sddr55_card_info *info;if (!us->extra) { - us->extra =kmalloc ( + us->extra =kzalloc (sizeof (struct sddr55_card_info ),GFP_NOIO );if (!us->extra)return USB_STOR_TRANSPORT_ERROR ; -memset (us->extra,0 ,sizeof (struct sddr55_card_info )); us->extra_destructor = sddr55_card_info_destructor; }
drivers/usb/misc/idmouse.c renamed from drivers/usb/misc/idmouse.c.orig +1 -2
@@ -340,10 +340,9 @@ static int idmouse_probe(struct usb_intereturn -ENODEV ;/* allocate memory for our device state and initialize it */ - dev =kmalloc (sizeof (*dev),GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (dev ==NULL )return -ENOMEM ; -memset (dev,0x00 ,sizeof (*dev));init_MUTEX (&dev->sem); dev->udev = udev;
drivers/usb/misc/usblcd.c renamed from drivers/usb/misc/usblcd.c.orig +1 -2
@@ -270,12 +270,11 @@ static int lcd_probe(struct usb_interfacint retval = -ENOMEM ;/* allocate memory for our device state and initialize it */ - dev =kmalloc (sizeof (*dev),GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (dev ==NULL ) {err ("Out of memory" ); goto error; } -memset (dev,0x00 ,sizeof (*dev));kref_init (&dev->kref); dev->udev =usb_get_dev (interface_to_usbdev (interface));
drivers/usb/misc/usbtest.c renamed from drivers/usb/misc/usbtest.c.orig +3 -6
@@ -382,12 +382,11 @@ alloc_sglist (int nents, int max, int vafor (i =0 ; i < nents; i++) {char *buf; - buf =kmalloc (size,SLAB_KERNEL ); + buf =kzalloc (size,SLAB_KERNEL );if (!buf) {free_sglist (sg, i);return NULL ; } -memset (buf,0 , size);/* kmalloc pages are always physically contiguous! */ sg_init_one (&sg[i], buf, size);
@@ -842,10 +841,9 @@ test_ctrl_queue (struct usbtest_dev *dev* as with bulk/intr sglists, sglen is the queue depth; it also * controls which subtests run (more tests than sglen) or rerun. */ - urb =kmalloc (param->sglen *sizeof (struct urb *),SLAB_KERNEL ); + urb =kcalloc (param->sglen,sizeof (struct urb *),SLAB_KERNEL );if (!urb)return -ENOMEM ; -memset (urb,0 , param->sglen *sizeof (struct urb *));for (i =0 ; i < param->sglen; i++) {int pipe =usb_rcvctrlpipe (udev,0 );unsigned len;
@@ -1865,10 +1863,9 @@ usbtest_probe (struct usb_interface *int }#endif - dev =kmalloc (sizeof *dev,SLAB_KERNEL ); + dev =kzalloc (sizeof (*dev),SLAB_KERNEL );if (!dev)return -ENOMEM ; -memset (dev,0 ,sizeof *dev); info = (struct usbtest_info *) id->driver_info; dev->info = info;init_MUTEX (&dev->sem);
drivers/usb/misc/ldusb.c renamed from drivers/usb/misc/ldusb.c.orig +1 -2
@@ -626,12 +626,11 @@ static int ld_usb_probe(struct usb_inter/* allocate memory for our device state and intialize it */ - dev =kmalloc (sizeof (*dev),GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (dev ==NULL ) {dev_err (&intf->dev,"Out of memory\n" ); goto exit; } -memset (dev,0x00 ,sizeof (*dev));init_MUTEX (&dev->sem); dev->intf = intf;init_waitqueue_head (&dev->read_wait);
drivers/usb/misc/phidgetservo.c renamed from drivers/usb/misc/phidgetservo.c.orig +1 -2
@@ -252,12 +252,11 @@ servo_probe(struct usb_interface *interfstruct usb_device *udev =interface_to_usbdev (interface);struct phidget_servo *dev; - dev =kmalloc (sizeof (struct phidget_servo ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct phidget_servo ),GFP_KERNEL );if (dev ==NULL ) {dev_err (&interface->dev,"%s - out of memory\n" , __FUNCTION__);return -ENOMEM ; } -memset (dev,0x00 ,sizeof (*dev)); dev->udev =usb_get_dev (udev); dev->type = id->driver_info;
drivers/usb/misc/usbled.c renamed from drivers/usb/misc/usbled.c.orig +1 -2
@@ -106,12 +106,11 @@ static int led_probe(struct usb_interfacstruct usb_led *dev =NULL ;int retval = -ENOMEM ; - dev =kmalloc (sizeof (struct usb_led ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct usb_led ),GFP_KERNEL );if (dev ==NULL ) {dev_err (&interface->dev,"Out of memory\n" ); goto error; } -memset (dev,0x00 ,sizeof (*dev)); dev->udev =usb_get_dev (udev);
drivers/usb/misc/auerswald.c renamed from drivers/usb/misc/auerswald.c.orig +2 -4
@@ -570,10 +570,9 @@ static int auerchain_setup (pauerchain_t/* fill the list of free elements */ for (;numElements; numElements--) { - acep = (pauerchainelement_t )kmalloc (sizeof (auerchainelement_t),GFP_KERNEL ); + acep =kzalloc (sizeof (auerchainelement_t),GFP_KERNEL );if (!acep) goto ac_fail; -memset (acep,0 ,sizeof (auerchainelement_t));INIT_LIST_HEAD (&acep->list);list_add_tail (&acep->list, &acp->free_list); }
@@ -761,10 +760,9 @@ static int auerbuf_setup (pauerbufctl_t/* fill the list of free elements */ for (;numElements; numElements--) { - bep = (pauerbuf_t )kmalloc (sizeof (auerbuf_t),GFP_KERNEL ); + bep =kzalloc (sizeof (auerbuf_t),GFP_KERNEL );if (!bep) goto bl_fail; -memset (bep,0 ,sizeof (auerbuf_t)); bep->list = bcp;INIT_LIST_HEAD (&bep->buff_list); bep->bufp =kmalloc (bufsize,GFP_KERNEL );
drivers/usb/misc/cytherm.c renamed from drivers/usb/misc/cytherm.c.orig +1 -2
@@ -351,12 +351,11 @@ static int cytherm_probe(struct usb_intestruct usb_cytherm *dev =NULL ;int retval = -ENOMEM ; - dev =kmalloc (sizeof (struct usb_cytherm ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct usb_cytherm ),GFP_KERNEL );if (dev ==NULL ) {dev_err (&interface->dev,"Out of memory\n" ); goto error; } -memset (dev,0x00 ,sizeof (*dev)); dev->udev =usb_get_dev (udev);
drivers/usb/misc/phidgetkit.c renamed from drivers/usb/misc/phidgetkit.c.orig +1 -2
@@ -406,12 +406,11 @@ static int interfacekit_probe(struct usb pipe =usb_rcvintpipe (dev, endpoint->bEndpointAddress); maxp =usb_maxpacket (dev, pipe,usb_pipeout (pipe)); - kit =kmalloc (sizeof (*kit),GFP_KERNEL ); + kit =kzalloc (sizeof (*kit),GFP_KERNEL );if (kit ==NULL ) {dev_err (&intf->dev,"%s - out of memory\n" , __FUNCTION__);return -ENOMEM ; } -memset (kit,0 ,sizeof (*kit)); kit->ifkit = ifkit; kit->data =usb_buffer_alloc (dev,8 ,SLAB_ATOMIC , &kit->data_dma);
drivers/usb/mon/mon_text.c renamed from drivers/usb/mon/mon_text.c.orig +1 -2
@@ -212,12 +212,11 @@ static int mon_text_open(struct inode *i mbus = inode->u.generic_ip; ubus = mbus->u_bus; - rp =kmalloc (sizeof (struct mon_reader_text ),GFP_KERNEL ); + rp =kzalloc (sizeof (struct mon_reader_text ),GFP_KERNEL );if (rp ==NULL ) { rc = -ENOMEM ; goto err_alloc; } -memset (rp,0 ,sizeof (struct mon_reader_text ));INIT_LIST_HEAD (&rp->e_list);init_waitqueue_head (&rp->wait);init_MUTEX (&rp->printf_lock);
drivers/usb/mon/mon_main.c renamed from drivers/usb/mon/mon_main.c.orig +1 -2
@@ -276,9 +276,8 @@ static void mon_bus_init(struct dentry *char name[NAMESZ ];int rc; -if ((mbus =kmalloc (sizeof (struct mon_bus ),GFP_KERNEL )) ==NULL ) +if ((mbus =kzalloc (sizeof (struct mon_bus ),GFP_KERNEL )) ==NULL ) goto err_alloc; -memset (mbus,0 ,sizeof (struct mon_bus ));kref_init (&mbus->ref);spin_lock_init (&mbus->lock);INIT_LIST_HEAD (&mbus->r_list);
drivers/usb/gadget/lh7a40x_udc.c renamed from drivers/usb/gadget/lh7a40x_udc.c.orig +1 -2
@@ -1114,11 +1114,10 @@ static struct usb_request *lh7a40x_allocDEBUG ("%s, %p\n" , __FUNCTION__, ep); - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (!req)return 0 ; -memset (req,0 ,sizeof *req);INIT_LIST_HEAD (&req->queue);return &req->req;
drivers/usb/gadget/inode.c renamed from drivers/usb/gadget/inode.c.orig +2 -4
@@ -170,10 +170,9 @@ static struct dev_data *dev_new (void) {struct dev_data *dev; - dev =kmalloc (sizeof *dev,GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return NULL ; -memset (dev,0 ,sizeof *dev); dev->state =STATE_DEV_DISABLED ;atomic_set (&dev->count,1 );spin_lock_init (&dev->lock);
@@ -1592,10 +1591,9 @@ static int activate_ep_files (struct dev gadget_for_each_ep (ep, dev->gadget) {struct ep_data *data; - data =kmalloc (sizeof *data,GFP_KERNEL ); + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data) goto enomem; -memset (data,0 ,sizeof data); data->state =STATE_EP_DISABLED ;init_MUTEX (&data->lock);init_waitqueue_head (&data->wait);
drivers/usb/gadget/goku_udc.c renamed from drivers/usb/gadget/goku_udc.c.orig +1 -2
@@ -275,11 +275,10 @@ goku_alloc_request(struct usb_ep *_ep, gif (!_ep)return NULL ; - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof *req, gfp_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req); req->req.dma =DMA_ADDR_INVALID ;INIT_LIST_HEAD (&req->queue);return &req->req;
drivers/usb/gadget/pxa2xx_udc.c renamed from drivers/usb/gadget/pxa2xx_udc.c.orig +1 -2
@@ -335,11 +335,10 @@ pxa2xx_ep_alloc_request (struct usb_ep * {struct pxa2xx_request *req; - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req);INIT_LIST_HEAD (&req->queue);return &req->req; }
drivers/usb/gadget/dummy_hcd.c renamed from drivers/usb/gadget/dummy_hcd.c.orig +1 -2
@@ -478,10 +478,9 @@ dummy_alloc_request (struct usb_ep *_ep,return NULL ; ep =usb_ep_to_dummy_ep (_ep); - req =kmalloc (sizeof *req, mem_flags); + req =kzalloc (sizeof (*req), mem_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req);INIT_LIST_HEAD (&req->queue);return &req->req; }
drivers/usb/gadget/zero.c renamed from drivers/usb/gadget/zero.c.orig +1 -2
@@ -1188,10 +1188,9 @@ autoconf_fail:/* ok, we made sense of the hardware ... */ - dev =kmalloc (sizeof *dev,SLAB_KERNEL ); + dev =kzalloc (sizeof (*dev),SLAB_KERNEL );if (!dev)return -ENOMEM ; -memset (dev,0 ,sizeof *dev);spin_lock_init (&dev->lock); dev->gadget = gadget;set_gadget_data (gadget, dev);
drivers/usb/gadget/serial.c renamed from drivers/usb/gadget/serial.c.orig +1 -2
@@ -2178,10 +2178,9 @@ static int gs_alloc_ports(struct gs_devreturn -EIO ;for (i=0 ; i<GS_NUM_PORTS ; i++) { -if ((port=(struct gs_port *)kmalloc (sizeof (struct gs_port ), kmalloc_flags)) ==NULL ) +if ((port=(struct gs_port *)kzalloc (sizeof (struct gs_port ), kmalloc_flags)) ==NULL )return -ENOMEM ; -memset (port,0 ,sizeof (struct gs_port )); port->port_dev = dev; port->port_num = i; port->port_line_coding.dwDTERate =cpu_to_le32 (GS_DEFAULT_DTE_RATE );
drivers/usb/gadget/net2280.c renamed from drivers/usb/gadget/net2280.c.orig +1 -2
@@ -386,11 +386,10 @@ net2280_alloc_request (struct usb_ep *_ereturn NULL ; ep = container_of (_ep, struct net2280_ep, ep); - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req); req->req.dma =DMA_ADDR_INVALID ;INIT_LIST_HEAD (&req->queue);
drivers/usb/gadget/omap_udc.c renamed from drivers/usb/gadget/omap_udc.c.orig +2 -4
@@ -273,9 +273,8 @@ omap_alloc_request(struct usb_ep *ep, gf {struct omap_req *req; - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (req) { -memset (req,0 ,sizeof *req); req->req.dma =DMA_ADDR_INVALID ;INIT_LIST_HEAD (&req->queue); }
@@ -2586,11 +2585,10 @@ omap_udc_setup(struct platform_device *o/* UDC_PULLUP_EN gates the chip clock */ // OTG_SYSCON_1_REG |= DEV_IDLE_EN; - udc =kmalloc (sizeof *udc,SLAB_KERNEL ); + udc =kzalloc (sizeof (*udc),SLAB_KERNEL );if (!udc)return -ENOMEM ; -memset (udc,0 ,sizeof *udc);spin_lock_init (&udc->lock); udc->gadget.ops = &omap_gadget_ops;
drivers/usb/input/hiddev.c renamed from drivers/usb/input/hiddev.c.orig +2 -4
@@ -257,9 +257,8 @@ static int hiddev_open(struct inode * inif (i >=HIDDEV_MINORS || !hiddev_table[i])return -ENODEV ; -if (!(list =kmalloc (sizeof (struct hiddev_list ),GFP_KERNEL ))) +if (!(list =kzalloc (sizeof (struct hiddev_list ),GFP_KERNEL )))return -ENOMEM ; -memset (list,0 ,sizeof (struct hiddev_list )); list->hiddev = hiddev_table[i]; list->next = hiddev_table[i]->list;
@@ -754,9 +753,8 @@ int hiddev_connect(struct hid_device *hiif (i == hid->maxcollection && (hid->quirks &HID_QUIRK_HIDDEV ) ==0 )return -1 ; -if (!(hiddev =kmalloc (sizeof (struct hiddev ),GFP_KERNEL ))) +if (!(hiddev =kzalloc (sizeof (struct hiddev ),GFP_KERNEL )))return -1 ; -memset (hiddev,0 ,sizeof (struct hiddev )); retval =usb_register_dev (hid->intf, &hiddev_class);if (retval) {
drivers/usb/input/hid-core.c renamed from drivers/usb/input/hid-core.c.orig +3 -7
@@ -66,9 +66,8 @@ static struct hid_report *hid_register_rif (report_enum->report_id_hash[id])return report_enum->report_id_hash[id]; -if (!(report =kmalloc (sizeof (struct hid_report ),GFP_KERNEL ))) +if (!(report =kzalloc (sizeof (struct hid_report ),GFP_KERNEL )))return NULL ; -memset (report,0 ,sizeof (struct hid_report ));if (id !=0 ) report_enum->numbered =1 ;
@@ -651,17 +650,14 @@ static struct hid_device *hid_parse_repo hid_parser_reserved }; -if (!(device =kmalloc (sizeof (struct hid_device ),GFP_KERNEL ))) +if (!(device =kzalloc (sizeof (struct hid_device ),GFP_KERNEL )))return NULL ; -memset (device,0 ,sizeof (struct hid_device )); -if (!(device->collection =kmalloc (sizeof (struct hid_collection ) * +if (!(device->collection =kzalloc (sizeof (struct hid_collection ) *HID_DEFAULT_NUM_COLLECTIONS ,GFP_KERNEL ))) {kfree (device);return NULL ; } -memset (device->collection,0 ,sizeof (struct hid_collection ) * -HID_DEFAULT_NUM_COLLECTIONS ); device->collection_size =HID_DEFAULT_NUM_COLLECTIONS ;for (i =0 ; i <HID_REPORT_TYPES ; i++)
drivers/usb/input/hid-lgff.c renamed from drivers/usb/input/hid-lgff.c.orig +1 -2
@@ -154,10 +154,9 @@ int hid_lgff_init(struct hid_device* hidreturn -1 ; } - private =kmalloc (sizeof (struct lgff_device ),GFP_KERNEL ); + private =kzalloc (sizeof (struct lgff_device ),GFP_KERNEL );if (!private)return -1 ; -memset (private,0 ,sizeof (struct lgff_device )); hid->ff_private = private;/* Input init */
drivers/usb/input/hid-tmff.c renamed from drivers/usb/input/hid-tmff.c.orig +1 -2
@@ -113,11 +113,10 @@ int hid_tmff_init(struct hid_device *hid struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list);struct input_dev *input_dev = hidinput->input; - private =kmalloc (sizeof (struct tmff_device ),GFP_KERNEL ); + private =kzalloc (sizeof (struct tmff_device ),GFP_KERNEL );if (!private)return -ENOMEM ; -memset (private,0 ,sizeof (struct tmff_device )); hid->ff_private = private;/* Find the report to use */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/usb/gadget
In reply to Eric Sesterhennhi,
this patch converts drivers/usb to kzalloc usage.
Compile tested with allyes config.
I think there was a bug in drivers/usb/gadget/inode.c because it used sizeof(*data) for the kmalloc() and sizeof(data) for the memset(), since sizeof(data) just returns the size for a pointer.
I assume there is also a bug in drivers/usb/gadget/omap_udc.c in omap_alloc_request(), req gets allocated via kmalloc() and the function returns &req->req, no matter if req is NULL, which looks like a NULL dereference to me, maybe someone who is more familar with this code might have a look at it.
drivers/usb/gadget/dummy_hcd.c +1 -2
@@ -478,10 +478,9 @@ dummy_alloc_request (struct usb_ep *_ep,return NULL ; ep =usb_ep_to_dummy_ep (_ep); - req =kmalloc (sizeof *req, mem_flags); + req =kzalloc (sizeof (*req), mem_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req);INIT_LIST_HEAD (&req->queue);return &req->req; }
drivers/usb/gadget/goku_udc.c +1 -2
@@ -275,11 +275,10 @@ goku_alloc_request(struct usb_ep *_ep, gif (!_ep)return NULL ; - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof *req, gfp_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req); req->req.dma =DMA_ADDR_INVALID ;INIT_LIST_HEAD (&req->queue);return &req->req;
drivers/usb/gadget/inode.c +2 -4
@@ -170,10 +170,9 @@ static struct dev_data *dev_new (void) {struct dev_data *dev; - dev =kmalloc (sizeof *dev,GFP_KERNEL ); + dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return NULL ; -memset (dev,0 ,sizeof *dev); dev->state =STATE_DEV_DISABLED ;atomic_set (&dev->count,1 );spin_lock_init (&dev->lock);
@@ -1592,10 +1591,9 @@ static int activate_ep_files (struct dev gadget_for_each_ep (ep, dev->gadget) {struct ep_data *data; - data =kmalloc (sizeof *data,GFP_KERNEL ); + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data) goto enomem; -memset (data,0 ,sizeof data); data->state =STATE_EP_DISABLED ;init_MUTEX (&data->lock);init_waitqueue_head (&data->wait);
drivers/usb/gadget/lh7a40x_udc.c +1 -2
@@ -1114,11 +1114,10 @@ static struct usb_request *lh7a40x_allocDEBUG ("%s, %p\n" , __FUNCTION__, ep); - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (!req)return 0 ; -memset (req,0 ,sizeof *req);INIT_LIST_HEAD (&req->queue);return &req->req;
drivers/usb/gadget/net2280.c +1 -2
@@ -386,11 +386,10 @@ net2280_alloc_request (struct usb_ep *_ereturn NULL ; ep = container_of (_ep, struct net2280_ep, ep); - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req); req->req.dma =DMA_ADDR_INVALID ;INIT_LIST_HEAD (&req->queue);
drivers/usb/gadget/omap_udc.c +2 -4
@@ -273,9 +273,8 @@ omap_alloc_request(struct usb_ep *ep, gf {struct omap_req *req; - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (req) { -memset (req,0 ,sizeof *req); req->req.dma =DMA_ADDR_INVALID ;INIT_LIST_HEAD (&req->queue); }
@@ -2586,11 +2585,10 @@ omap_udc_setup(struct platform_device *o/* UDC_PULLUP_EN gates the chip clock */ // OTG_SYSCON_1_REG |= DEV_IDLE_EN; - udc =kmalloc (sizeof *udc,SLAB_KERNEL ); + udc =kzalloc (sizeof (*udc),SLAB_KERNEL );if (!udc)return -ENOMEM ; -memset (udc,0 ,sizeof *udc);spin_lock_init (&udc->lock); udc->gadget.ops = &omap_gadget_ops;
drivers/usb/gadget/pxa2xx_udc.c +1 -2
@@ -335,11 +335,10 @@ pxa2xx_ep_alloc_request (struct usb_ep * {struct pxa2xx_request *req; - req =kmalloc (sizeof *req, gfp_flags); + req =kzalloc (sizeof (*req), gfp_flags);if (!req)return NULL ; -memset (req,0 ,sizeof *req);INIT_LIST_HEAD (&req->queue);return &req->req; }
drivers/usb/gadget/serial.c +1 -2
@@ -2178,10 +2178,9 @@ static int gs_alloc_ports(struct gs_devreturn -EIO ;for (i=0 ; i<GS_NUM_PORTS ; i++) { -if ((port=(struct gs_port *)kmalloc (sizeof (struct gs_port ), kmalloc_flags)) ==NULL ) +if ((port=kzalloc (sizeof (struct gs_port ), kmalloc_flags)) ==NULL )return -ENOMEM ; -memset (port,0 ,sizeof (struct gs_port )); port->port_dev = dev; port->port_num = i; port->port_line_coding.dwDTERate =cpu_to_le32 (GS_DEFAULT_DTE_RATE );
drivers/usb/gadget/zero.c +1 -2
@@ -1188,10 +1188,9 @@ autoconf_fail:/* ok, we made sense of the hardware ... */ - dev =kmalloc (sizeof *dev,SLAB_KERNEL ); + dev =kzalloc (sizeof (*dev),SLAB_KERNEL );if (!dev)return -ENOMEM ; -memset (dev,0 ,sizeof *dev);spin_lock_init (&dev->lock); dev->gadget = gadget;set_gadget_data (gadget, dev);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
In reply to Eric SesterhennQuoted 9 lines · Eric Sesterhenn
hi,
this patch converts
drivers/usbto kzalloc usage. Compile tested with allyes config.I think there was a bug in
drivers/usb/gadget/inode.cbecause it usedsizeof(*data)for thekmalloc()and sizeof(data) for thememset(), since sizeof(data) just returns the size for a pointer.
I don't know this code well, but looking briefly at it I'd say your analysis is correct and your patch fixes that bug.
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/acpi
In reply to Eric Sesterhennhi,
this patch converts drivers/acpi to kzalloc usage. Compile tested with allyes config.
drivers/acpi/utils.c renamed from drivers/acpi/utils.c.orig +2 -4
@@ -264,11 +264,10 @@ acpi_evaluate_integer(acpi_handle handleif (!data)return_ACPI_STATUS (AE_BAD_PARAMETER ); - element =kmalloc (sizeof (union acpi_object ),GFP_KERNEL ); + element =kzalloc (sizeof (union acpi_object ),GFP_KERNEL );if (!element)return_ACPI_STATUS (AE_NO_MEMORY ); -memset (element,0 ,sizeof (union acpi_object )); buffer.length =sizeof (union acpi_object ); buffer.pointer = element; status =acpi_evaluate_object (handle, pathname, arguments, &buffer);
@@ -322,12 +321,11 @@ acpi_evaluate_string(acpi_handle handle,return_ACPI_STATUS (AE_BAD_DATA ); } - *data =kmalloc (element->string.length +1 ,GFP_KERNEL ); + *data =kzalloc (element->string.length +1 ,GFP_KERNEL );if (!data) {ACPI_ERROR ((AE_INFO ,"Memory allocation" ));return_VALUE (-ENOMEM ); } -memset (*data,0 , element->string.length +1 );memcpy (*data, element->string.pointer, element->string.length);
drivers/acpi/pci_irq.c renamed from drivers/acpi/pci_irq.c.orig +4 -8
@@ -92,10 +92,9 @@ acpi_pci_irq_add_entry(acpi_handle handlif (!prt)return_VALUE (-EINVAL ); - entry =kmalloc (sizeof (struct acpi_prt_entry ),GFP_KERNEL ); + entry =kzalloc (sizeof (struct acpi_prt_entry ),GFP_KERNEL );if (!entry)return_VALUE (-ENOMEM ); -memset (entry,0 ,sizeof (struct acpi_prt_entry )); entry->id.segment = segment; entry->id.bus = bus;
@@ -165,10 +164,9 @@ int acpi_pci_irq_add_prt(acpi_handle hanACPI_FUNCTION_TRACE ("acpi_pci_irq_add_prt" ); - pathname = (char *)kmalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL ); + pathname =kzalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL );if (!pathname)return_VALUE (-ENOMEM ); -memset (pathname,0 ,ACPI_PATHNAME_MAX );if (first_time) { acpi_prt.count =0 ;
@@ -202,11 +200,9 @@ int acpi_pci_irq_add_prt(acpi_handle hanreturn_VALUE (-ENODEV ); } - prt =kmalloc (buffer.length,GFP_KERNEL ); -if (!prt) { + prt =kzalloc (buffer.length,GFP_KERNEL ); +if (!prt)return_VALUE (-ENOMEM ); - } -memset (prt,0 , buffer.length); buffer.pointer = prt; status =acpi_get_irq_routing_table (handle, &buffer);
drivers/acpi/asus_acpi.c renamed from drivers/acpi/asus_acpi.c.orig +1 -3
@@ -1132,11 +1132,9 @@ static int __init asus_hotk_add(struct aprintk (KERN_NOTICE "Asus Laptop ACPI Extras version %s\n" ,ASUS_ACPI_VERSION ); - hotk = - (struct asus_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),ACPI_HOTK_DEVICE_NAME );
drivers/acpi/acpi_memhotplug.c renamed from drivers/acpi/acpi_memhotplug.c.orig +1 -2
@@ -342,10 +342,9 @@ static int acpi_memory_device_add(structif (!device)return_VALUE (-EINVAL ); - mem_device =kmalloc (sizeof (struct acpi_memory_device ),GFP_KERNEL ); + mem_device =kzalloc (sizeof (struct acpi_memory_device ),GFP_KERNEL );if (!mem_device)return_VALUE (-ENOMEM ); -memset (mem_device,0 ,sizeof (struct acpi_memory_device )); mem_device->handle = device->handle;sprintf (acpi_device_name (device),"%s" ,ACPI_MEMORY_DEVICE_NAME );
drivers/acpi/scan.c renamed from drivers/acpi/scan.c.orig +1 -2
@@ -982,12 +982,11 @@ acpi_add_single_object(struct acpi_devicif (!child)return_VALUE (-EINVAL ); - device =kmalloc (sizeof (struct acpi_device ),GFP_KERNEL ); + device =kzalloc (sizeof (struct acpi_device ),GFP_KERNEL );if (!device) {ACPI_ERROR ((AE_INFO ,"Memory allocation error" ));return_VALUE (-ENOMEM ); } -memset (device,0 ,sizeof (struct acpi_device )); device->handle = handle; device->parent = parent;
drivers/acpi/battery.c renamed from drivers/acpi/battery.c.orig +3 -6
@@ -156,12 +156,11 @@ acpi_battery_get_info(struct acpi_batter goto end; } - data.pointer =kmalloc (data.length,GFP_KERNEL ); + data.pointer =kzalloc (data.length,GFP_KERNEL );if (!data.pointer) { result = -ENOMEM ; goto end; } -memset (data.pointer,0 , data.length); status =acpi_extract_package (package, &format, &data);if (ACPI_FAILURE (status)) {
@@ -217,12 +216,11 @@ acpi_battery_get_status(struct acpi_batt goto end; } - data.pointer =kmalloc (data.length,GFP_KERNEL ); + data.pointer =kzalloc (data.length,GFP_KERNEL );if (!data.pointer) { result = -ENOMEM ; goto end; } -memset (data.pointer,0 , data.length); status =acpi_extract_package (package, &format, &data);if (ACPI_FAILURE (status)) {
@@ -702,10 +700,9 @@ static int acpi_battery_add(struct acpi_if (!device)return_VALUE (-EINVAL ); - battery =kmalloc (sizeof (struct acpi_battery ),GFP_KERNEL ); + battery =kzalloc (sizeof (struct acpi_battery ),GFP_KERNEL );if (!battery)return_VALUE (-ENOMEM ); -memset (battery,0 ,sizeof (struct acpi_battery )); battery->handle = device->handle;strcpy (acpi_device_name (device),ACPI_BATTERY_DEVICE_NAME );
drivers/acpi/button.c renamed from drivers/acpi/button.c.orig +1 -2
@@ -304,10 +304,9 @@ static int acpi_button_add(struct acpi_dif (!device)return_VALUE (-EINVAL ); - button =kmalloc (sizeof (struct acpi_button ),GFP_KERNEL ); + button =kzalloc (sizeof (struct acpi_button ),GFP_KERNEL );if (!button)return_VALUE (-ENOMEM ); -memset (button,0 ,sizeof (struct acpi_button )); button->device = device; button->handle = device->handle;
drivers/acpi/ec.c renamed from drivers/acpi/ec.c.orig +5 -10
@@ -996,10 +996,9 @@ static int acpi_ec_poll_add(struct acpi_if (!device)return_VALUE (-EINVAL ); - ec =kmalloc (sizeof (union acpi_ec ),GFP_KERNEL ); + ec =kzalloc (sizeof (union acpi_ec ),GFP_KERNEL );if (!ec)return_VALUE (-ENOMEM ); -memset (ec,0 ,sizeof (union acpi_ec )); ec->common.handle = device->handle; ec->common.uid =-1 ;
@@ -1066,10 +1065,9 @@ static int acpi_ec_intr_add(struct acpi_if (!device)return_VALUE (-EINVAL ); - ec =kmalloc (sizeof (union acpi_ec ),GFP_KERNEL ); + ec =kzalloc (sizeof (union acpi_ec ),GFP_KERNEL );if (!ec)return_VALUE (-ENOMEM ); -memset (ec,0 ,sizeof (union acpi_ec )); ec->common.handle = device->handle; ec->common.uid =-1 ;
@@ -1357,12 +1355,11 @@ static int __init acpi_ec_fake_ecdt(void printk(KERN_INFO PREFIX "Try to make an fake ECDT\n"); - ec_ecdt =kmalloc (sizeof (union acpi_ec ),GFP_KERNEL ); + ec_ecdt =kzalloc (sizeof (union acpi_ec ),GFP_KERNEL );if (!ec_ecdt) { ret = -ENOMEM ; goto error; } -memset (ec_ecdt,0 ,sizeof (union acpi_ec )); status =acpi_get_devices (ACPI_EC_HID , acpi_fake_ecdt_callback,NULL ,NULL );
@@ -1402,10 +1399,9 @@ static int __init acpi_ec_poll_get_real_/* * Generate a temporary ec context to use until the namespace is scanned */ - ec_ecdt =kmalloc (sizeof (union acpi_ec ),GFP_KERNEL ); + ec_ecdt =kzalloc (sizeof (union acpi_ec ),GFP_KERNEL );if (!ec_ecdt)return -ENOMEM ; -memset (ec_ecdt,0 ,sizeof (union acpi_ec )); ec_ecdt->common.command_addr = ecdt_ptr->ec_control; ec_ecdt->common.status_addr = ecdt_ptr->ec_control;
@@ -1447,10 +1443,9 @@ static int __init acpi_ec_intr_get_real_/* * Generate a temporary ec context to use until the namespace is scanned */ - ec_ecdt =kmalloc (sizeof (union acpi_ec ),GFP_KERNEL ); + ec_ecdt =kzalloc (sizeof (union acpi_ec ),GFP_KERNEL );if (!ec_ecdt)return -ENOMEM ; -memset (ec_ecdt,0 ,sizeof (union acpi_ec ));init_MUTEX (&ec_ecdt->intr.sem);init_waitqueue_head (&ec_ecdt->intr.wait);
drivers/acpi/pci_link.c renamed from drivers/acpi/pci_link.c.orig +2 -4
@@ -314,11 +314,10 @@ static int acpi_pci_link_set(struct acpiif (!link || !irq)return_VALUE (-EINVAL ); - resource =kmalloc (sizeof (*resource) +1 ,GFP_ATOMIC ); + resource =kzalloc (sizeof (*resource) +1 ,GFP_ATOMIC );if (!resource)return_VALUE (-ENOMEM ); -memset (resource,0 ,sizeof (*resource) +1 ); buffer.length =sizeof (*resource) +1 ; buffer.pointer = resource;
@@ -730,10 +729,9 @@ static int acpi_pci_link_add(struct acpiif (!device)return_VALUE (-EINVAL ); - link =kmalloc (sizeof (struct acpi_pci_link ),GFP_KERNEL ); + link =kzalloc (sizeof (struct acpi_pci_link ),GFP_KERNEL );if (!link)return_VALUE (-ENOMEM ); -memset (link,0 ,sizeof (struct acpi_pci_link )); link->device = device; link->handle = device->handle;
drivers/acpi/ac.c renamed from drivers/acpi/ac.c.orig +1 -2
@@ -224,10 +224,9 @@ static int acpi_ac_add(struct acpi_devicif (!device)return_VALUE (-EINVAL ); - ac =kmalloc (sizeof (struct acpi_ac ),GFP_KERNEL ); + ac =kzalloc (sizeof (struct acpi_ac ),GFP_KERNEL );if (!ac)return_VALUE (-ENOMEM ); -memset (ac,0 ,sizeof (struct acpi_ac )); ac->handle = device->handle;strcpy (acpi_device_name (device),ACPI_AC_DEVICE_NAME );
drivers/acpi/thermal.c renamed from drivers/acpi/thermal.c.orig +2 -5
@@ -933,12 +933,10 @@ acpi_thermal_write_trip_points(struct fiACPI_FUNCTION_TRACE ("acpi_thermal_write_trip_points" ); - limit_string =kmalloc (ACPI_THERMAL_MAX_LIMIT_STR_LEN ,GFP_KERNEL ); + limit_string =kzalloc (ACPI_THERMAL_MAX_LIMIT_STR_LEN ,GFP_KERNEL );if (!limit_string)return_VALUE (-ENOMEM ); -memset (limit_string,0 ,ACPI_THERMAL_MAX_LIMIT_STR_LEN ); - active =kmalloc (ACPI_THERMAL_MAX_ACTIVE *sizeof (int ),GFP_KERNEL );if (!active)return_VALUE (-ENOMEM );
@@ -1310,10 +1308,9 @@ static int acpi_thermal_add(struct acpi_if (!device)return_VALUE (-EINVAL ); - tz =kmalloc (sizeof (struct acpi_thermal ),GFP_KERNEL ); + tz =kzalloc (sizeof (struct acpi_thermal ),GFP_KERNEL );if (!tz)return_VALUE (-ENOMEM ); -memset (tz,0 ,sizeof (struct acpi_thermal )); tz->handle = device->handle;strcpy (tz->name, device->pnp.bus_id);
drivers/acpi/ibm_acpi.c renamed from drivers/acpi/ibm_acpi.c.orig +1 -2
@@ -1750,13 +1750,12 @@ static int __init register_driver(struct {int ret; - ibm->driver =kmalloc (sizeof (struct acpi_driver ),GFP_KERNEL ); + ibm->driver =kzalloc (sizeof (struct acpi_driver ),GFP_KERNEL );if (!ibm->driver) {printk (IBM_ERR "kmalloc(ibm->driver) failed\n" );return -1 ; } -memset (ibm->driver,0 ,sizeof (struct acpi_driver ));sprintf (ibm->driver->name,"%s/%s" ,IBM_NAME , ibm->name); ibm->driver->ids = ibm->hid; ibm->driver->ops.add = &ibm_device_add;
drivers/acpi/container.c renamed from drivers/acpi/container.c.orig +1 -2
@@ -98,11 +98,10 @@ static int acpi_container_add(struct acpreturn_VALUE (-EINVAL ); } - container =kmalloc (sizeof (struct acpi_container ),GFP_KERNEL ); + container =kzalloc (sizeof (struct acpi_container ),GFP_KERNEL );if (!container)return_VALUE (-ENOMEM ); -memset (container,0 ,sizeof (struct acpi_container )); container->handle = device->handle;strcpy (acpi_device_name (device),ACPI_CONTAINER_DEVICE_NAME );strcpy (acpi_device_class (device),ACPI_CONTAINER_CLASS );
drivers/acpi/hotkey.c renamed from drivers/acpi/hotkey.c.orig +3 -6
@@ -247,10 +247,8 @@ static char *format_result(union acpi_ob {char *buf =NULL ; - buf = (char *)kmalloc (RESULT_STR_LEN ,GFP_KERNEL ); -if (buf) -memset (buf,0 ,RESULT_STR_LEN ); -else + buf =kzalloc (RESULT_STR_LEN ,GFP_KERNEL ); +if (!buf) goto do_fail;/* Now, just support integer type */
@@ -791,10 +789,9 @@ static ssize_t hotkey_write_config(strucreturn_VALUE (-EINVAL ); } - key =kmalloc (sizeof (union acpi_hotkey ),GFP_KERNEL ); + key =kzalloc (sizeof (union acpi_hotkey ),GFP_KERNEL );if (!key) goto do_fail; -memset (key,0 ,sizeof (union acpi_hotkey ));if (cmd ==1 ) {union acpi_hotkey *tmp =NULL ; tmp = get_hotkey_by_event(&global_hotkey_list,
drivers/acpi/pci_root.c renamed from drivers/acpi/pci_root.c.orig +1 -2
@@ -165,10 +165,9 @@ static int acpi_pci_root_add(struct acpiif (!device)return_VALUE (-EINVAL ); - root =kmalloc (sizeof (struct acpi_pci_root ),GFP_KERNEL ); + root =kzalloc (sizeof (struct acpi_pci_root ),GFP_KERNEL );if (!root)return_VALUE (-ENOMEM ); -memset (root,0 ,sizeof (struct acpi_pci_root ));INIT_LIST_HEAD (&root->node); root->handle = device->handle;
drivers/acpi/power.c renamed from drivers/acpi/power.c.orig +1 -2
@@ -552,10 +552,9 @@ static int acpi_power_add(struct acpi_deif (!device)return_VALUE (-EINVAL ); - resource =kmalloc (sizeof (struct acpi_power_resource ),GFP_KERNEL ); + resource =kzalloc (sizeof (struct acpi_power_resource ),GFP_KERNEL );if (!resource)return_VALUE (-ENOMEM ); -memset (resource,0 ,sizeof (struct acpi_power_resource )); resource->handle = device->handle;strcpy (resource->name, device->pnp.bus_id);
drivers/acpi/pci_bind.c renamed from drivers/acpi/pci_bind.c.orig +5 -10
@@ -125,19 +125,17 @@ int acpi_pci_bind(struct acpi_device *deif (!device || !device->parent)return_VALUE (-EINVAL ); - pathname =kmalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL ); + pathname =kzalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL );if (!pathname)return_VALUE (-ENOMEM ); -memset (pathname,0 ,ACPI_PATHNAME_MAX ); buffer.length =ACPI_PATHNAME_MAX ; buffer.pointer = pathname; - data =kmalloc (sizeof (struct acpi_pci_data ),GFP_KERNEL ); + data =kzalloc (sizeof (struct acpi_pci_data ),GFP_KERNEL );if (!data) {kfree (pathname);return_VALUE (-ENOMEM ); } -memset (data,0 ,sizeof (struct acpi_pci_data ));acpi_get_name (device->handle,ACPI_FULL_PATHNAME , &buffer); ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Binding PCI device [%s]...\n",
@@ -285,10 +283,9 @@ int acpi_pci_unbind(struct acpi_device *if (!device || !device->parent)return_VALUE (-EINVAL ); - pathname = (char *)kmalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL ); + pathname =kzalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL );if (!pathname)return_VALUE (-ENOMEM ); -memset (pathname,0 ,ACPI_PATHNAME_MAX ); buffer.length =ACPI_PATHNAME_MAX ; buffer.pointer = pathname;
@@ -337,10 +334,9 @@ acpi_pci_bind_root(struct acpi_device *dACPI_FUNCTION_TRACE ("acpi_pci_bind_root" ); - pathname = (char *)kmalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL ); + pathname =kzalloc (ACPI_PATHNAME_MAX ,GFP_KERNEL );if (!pathname)return_VALUE (-ENOMEM ); -memset (pathname,0 ,ACPI_PATHNAME_MAX ); buffer.length =ACPI_PATHNAME_MAX ; buffer.pointer = pathname;
@@ -350,12 +346,11 @@ acpi_pci_bind_root(struct acpi_device *dreturn_VALUE (-EINVAL ); } - data =kmalloc (sizeof (struct acpi_pci_data ),GFP_KERNEL ); + data =kzalloc (sizeof (struct acpi_pci_data ),GFP_KERNEL );if (!data) {kfree (pathname);return_VALUE (-ENOMEM ); } -memset (data,0 ,sizeof (struct acpi_pci_data )); data->id = *id; data->bus = bus;
drivers/acpi/fan.c renamed from drivers/acpi/fan.c.orig +1 -2
@@ -187,10 +187,9 @@ static int acpi_fan_add(struct acpi_deviif (!device)return_VALUE (-EINVAL ); - fan =kmalloc (sizeof (struct acpi_fan ),GFP_KERNEL ); + fan =kzalloc (sizeof (struct acpi_fan ),GFP_KERNEL );if (!fan)return_VALUE (-ENOMEM ); -memset (fan,0 ,sizeof (struct acpi_fan )); fan->handle = device->handle;strcpy (acpi_device_name (device),"Fan" );
drivers/acpi/video.c renamed from drivers/acpi/video.c.orig +3 -7
@@ -546,11 +546,10 @@ static void acpi_video_device_find_cap(sint count =0 ;union acpi_object *o; - br =kmalloc (sizeof (*br),GFP_KERNEL ); + br =kzalloc (sizeof (*br),GFP_KERNEL );if (!br) {printk (KERN_ERR "can't allocate memory\n" ); }else { -memset (br,0 ,sizeof (*br)); br->levels =kmalloc (obj->package.count *sizeof *(br->levels),GFP_KERNEL );if (!br->levels)
@@ -1296,12 +1295,10 @@ acpi_video_bus_get_one_device(struct acpacpi_evaluate_integer (device->handle,"_ADR" ,NULL , &device_id);if (ACPI_SUCCESS (status)) { - data =kmalloc (sizeof (struct acpi_video_device ),GFP_KERNEL ); + data =kzalloc (sizeof (struct acpi_video_device ),GFP_KERNEL );if (!data)return_VALUE (-ENOMEM ); -memset (data,0 ,sizeof (struct acpi_video_device )); - data->handle = device->handle;strcpy (acpi_device_name (device),ACPI_VIDEO_DEVICE_NAME );strcpy (acpi_device_class (device),ACPI_VIDEO_CLASS );
@@ -1737,10 +1734,9 @@ static int acpi_video_bus_add(struct acpif (!device)return_VALUE (-EINVAL ); - video =kmalloc (sizeof (struct acpi_video_bus ),GFP_KERNEL ); + video =kzalloc (sizeof (struct acpi_video_bus ),GFP_KERNEL );if (!video)return_VALUE (-ENOMEM ); -memset (video,0 ,sizeof (struct acpi_video_bus )); video->handle = device->handle;strcpy (acpi_device_name (device),ACPI_VIDEO_BUS_NAME );
drivers/acpi/processor_core.c renamed from drivers/acpi/processor_core.c.orig +1 -2
@@ -625,10 +625,9 @@ static int acpi_processor_add(struct acpif (!device)return_VALUE (-EINVAL ); - pr =kmalloc (sizeof (struct acpi_processor ),GFP_KERNEL ); + pr =kzalloc (sizeof (struct acpi_processor ),GFP_KERNEL );if (!pr)return_VALUE (-ENOMEM ); -memset (pr,0 ,sizeof (struct acpi_processor )); pr->handle = device->handle;strcpy (acpi_device_name (device),ACPI_PROCESSOR_DEVICE_NAME );
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/s390
In reply to Eric Sesterhennhi,
this patch converts drivers/s390 to kzalloc usage. Not compile tested.
drivers/s390/net/qeth_main.c renamed from drivers/s390/net/qeth_main.c.orig +6 -14
@@ -297,12 +297,10 @@ qeth_alloc_card(void)struct qeth_card *card;QETH_DBF_TEXT (setup,2 ,"alloccrd" ); - card = (struct qeth_card *)kmalloc (sizeof (struct qeth_card ), -GFP_DMA |GFP_KERNEL ); + card =kzalloc (sizeof (struct qeth_card ),GFP_DMA |GFP_KERNEL );if (!card)return NULL ;QETH_DBF_HEX (setup,2 , &card,sizeof (void *)); -memset (card,0 ,sizeof (struct qeth_card ));if (qeth_setup_channel (&card->read)) {kfree (card);return NULL ;
@@ -1632,9 +1630,8 @@ qeth_alloc_reply(struct qeth_card *card) {struct qeth_reply *reply; - reply =kmalloc (sizeof (struct qeth_reply ),GFP_ATOMIC ); + reply =kzalloc (sizeof (struct qeth_reply ),GFP_ATOMIC );if (reply){ -memset (reply,0 ,sizeof (struct qeth_reply ));atomic_set (&reply->refcnt,1 ); reply->card = card; };
@@ -3348,13 +3345,11 @@ qeth_qdio_establish(struct qeth_card *caQETH_DBF_TEXT (setup,2 ,"qdioest" ); - qib_param_field =kmalloc (QDIO_MAX_BUFFERS_PER_Q *sizeof (char ), + qib_param_field =kzalloc (QDIO_MAX_BUFFERS_PER_Q *sizeof (char ),GFP_KERNEL );if (!qib_param_field)return -ENOMEM ; -memset (qib_param_field,0 ,QDIO_MAX_BUFFERS_PER_Q *sizeof (char )); -qeth_create_qib_param_field (card, qib_param_field);qeth_create_qib_param_field_blkt (card, qib_param_field);
@@ -4844,9 +4839,8 @@ qeth_arp_query(struct qeth_card *card, c/* get size of userspace buffer and mask_bits -> 6 bytes */ if (copy_from_user (&qinfo, udata,6 ))return -EFAULT ; -if (!(qinfo.udata =kmalloc (qinfo.udata_len,GFP_KERNEL ))) +if (!(qinfo.udata =kzalloc (qinfo.udata_len,GFP_KERNEL )))return -ENOMEM ; -memset (qinfo.udata,0 , qinfo.udata_len); qinfo.udata_offset =QETH_QARP_ENTRIES_OFFSET ; iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING, IPA_CMD_ASS_ARP_QUERY_INFO,
@@ -4994,11 +4988,10 @@ qeth_snmp_command(struct qeth_card *cardreturn -EFAULT ; } qinfo.udata_len = ureq->hdr.data_len; -if (!(qinfo.udata =kmalloc (qinfo.udata_len,GFP_KERNEL ))){ +if (!(qinfo.udata =kzalloc (qinfo.udata_len,GFP_KERNEL ))){kfree (ureq);return -ENOMEM ; } -memset (qinfo.udata,0 , qinfo.udata_len); qinfo.udata_offset =sizeof (struct qeth_snmp_ureq_hdr ); iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL,
@@ -5604,12 +5597,11 @@ qeth_get_addr_buffer(enum qeth_prot_vers {struct qeth_ipaddr *addr; - addr =kmalloc (sizeof (struct qeth_ipaddr ),GFP_ATOMIC ); + addr =kzalloc (sizeof (struct qeth_ipaddr ),GFP_ATOMIC );if (addr ==NULL ) {PRINT_WARN ("Not enough memory to add address\n" );return NULL ; } -memset (addr,0 ,sizeof (struct qeth_ipaddr )); addr->type =QETH_IP_TYPE_NORMAL ; addr->proto = prot;return addr;
drivers/s390/net/qeth_sys.c renamed from drivers/s390/net/qeth_sys.c.orig +1 -2
@@ -1145,11 +1145,10 @@ qeth_dev_ipato_add_store(const char *bufif ((rc =qeth_parse_ipatoe (buf, proto, addr, &mask_bits)))return rc; -if (!(ipatoe =kmalloc (sizeof (struct qeth_ipato_entry ),GFP_KERNEL ))){ +if (!(ipatoe =kzalloc (sizeof (struct qeth_ipato_entry ),GFP_KERNEL ))){PRINT_WARN ("No memory to allocate ipato entry\n" );return -ENOMEM ; } -memset (ipatoe,0 ,sizeof (struct qeth_ipato_entry )); ipatoe->proto = proto;memcpy (ipatoe->addr, addr, (proto ==QETH_PROT_IPV4 )?4 :16 ); ipatoe->mask_bits = mask_bits;
drivers/s390/net/lcs.c renamed from drivers/s390/net/lcs.c.orig +4 -7
@@ -115,11 +115,10 @@ lcs_alloc_channel(struct lcs_channel *chLCS_DBF_TEXT (2 , setup,"ichalloc" );for (cnt =0 ; cnt <LCS_NUM_BUFFS ; cnt++) {/* alloc memory fo iobuffer */ - channel->iob[cnt].data = (void *) -kmalloc (LCS_IOBUFFERSIZE ,GFP_DMA |GFP_KERNEL ); + channel->iob[cnt].data = +kzalloc (LCS_IOBUFFERSIZE ,GFP_DMA |GFP_KERNEL );if (channel->iob[cnt].data ==NULL )break ; -memset (channel->iob[cnt].data,0 ,LCS_IOBUFFERSIZE ); channel->iob[cnt].state =BUF_STATE_EMPTY ; }if (cnt <LCS_NUM_BUFFS ) {
@@ -182,10 +181,9 @@ lcs_alloc_card(void)LCS_DBF_TEXT (2 , setup,"alloclcs" ); - card =kmalloc (sizeof (struct lcs_card ),GFP_KERNEL |GFP_DMA ); + card =kzalloc (sizeof (struct lcs_card ),GFP_KERNEL |GFP_DMA );if (card ==NULL )return NULL ; -memset (card,0 ,sizeof (struct lcs_card )); card->lan_type =LCS_FRAME_TYPE_AUTO ; card->pkt_seq =0 ; card->lancmd_timeout =LCS_LANCMD_TIMEOUT_DEFAULT ;
@@ -793,10 +791,9 @@ lcs_alloc_reply(struct lcs_cmd *cmd)LCS_DBF_TEXT (4 , trace,"getreply" ); - reply =kmalloc (sizeof (struct lcs_reply ),GFP_ATOMIC ); + reply =kzalloc (sizeof (struct lcs_reply ),GFP_ATOMIC );if (!reply)return NULL ; -memset (reply,0 ,sizeof (struct lcs_reply ));atomic_set (&reply->refcnt,1 ); reply->sequence_no = cmd->sequence_no; reply->received =0 ;
drivers/s390/net/ctctty.c renamed from drivers/s390/net/ctctty.c.orig +1 -2
@@ -1122,12 +1122,11 @@ ctc_tty_init(void)struct tty_driver *device;DBF_TEXT (trace,2 , __FUNCTION__); - driver =kmalloc (sizeof (ctc_tty_driver),GFP_KERNEL ); + driver =kzalloc (sizeof (ctc_tty_driver),GFP_KERNEL );if (driver ==NULL ) {printk (KERN_WARNING "Out of memory in ctc_tty_modem_init\n" );return -ENOMEM ; } -memset (driver,0 ,sizeof (ctc_tty_driver)); device =alloc_tty_driver (CTC_TTY_MAX_DEVICES );if (!device) {kfree (driver);
drivers/s390/net/claw.c renamed from drivers/s390/net/claw.c.orig +1 -2
@@ -310,7 +310,7 @@ claw_probe(struct ccwgroup_device *cgdevprintk (KERN_INFO "claw: variable cgdev =\n" );dumpit ((char *)cgdev,sizeof (struct ccwgroup_device ));#endif - privptr =kmalloc (sizeof (struct claw_privbk ),GFP_KERNEL ); + privptr =kzalloc (sizeof (struct claw_privbk ),GFP_KERNEL );if (privptr ==NULL ) {probe_error (cgdev);put_device (&cgdev->dev);
@@ -319,7 +319,6 @@ claw_probe(struct ccwgroup_device *cgdevCLAW_DBF_TEXT_ (2 ,setup,"probex%d" ,-ENOMEM );return -ENOMEM ; } -memset (privptr,0x00 ,sizeof (struct claw_privbk )); privptr->p_mtc_envelope=kmalloc (MAX_ENVELOPE_SIZE ,GFP_KERNEL ); privptr->p_env =kmalloc (sizeof (struct claw_env ),GFP_KERNEL );if ((privptr->p_mtc_envelope==NULL ) || (privptr->p_env==NULL )) {
drivers/s390/net/fsm.c renamed from drivers/s390/net/fsm.c.orig +3 -7
@@ -21,38 +21,34 @@ init_fsm(char *name, const char **state_fsm_function_t *m;fsm *f; - this = (fsm_instance *)kmalloc (sizeof (fsm_instance), order); + this =kzalloc (sizeof (fsm_instance), order);if (this ==NULL ) {printk (KERN_WARNING "fsm(%s): init_fsm: Couldn't alloc instance\n" , name);return NULL ; } -memset (this,0 ,sizeof (fsm_instance));strlcpy (this->name, name,sizeof (this->name)); - f = (fsm *)kmalloc (sizeof (fsm), order); + f =kzalloc (sizeof (fsm), order);if (f ==NULL ) {printk (KERN_WARNING "fsm(%s): init_fsm: Couldn't alloc fsm\n" , name);kfree_fsm (this);return NULL ; } -memset (f,0 ,sizeof (fsm)); f->nr_events = nr_events; f->nr_states = nr_states; f->event_names = event_names; f->state_names = state_names; this->f = f; - m = (fsm_function_t *)kmalloc ( -sizeof (fsm_function_t) * nr_states * nr_events, order); + m =kcalloc (nr_states*nr_events,sizeof (fsm_function_t), order);if (m ==NULL ) {printk (KERN_WARNING "fsm(%s): init_fsm: Couldn't alloc jumptable\n" , name);kfree_fsm (this);return NULL ; } -memset (m,0 ,sizeof (fsm_function_t) * f->nr_states * f->nr_events); f->jumpmatrix = m;for (i =0 ; i < tmpl_len; i++) {
drivers/s390/net/qeth_eddp.c renamed from drivers/s390/net/qeth_eddp.c.orig +4 -9
@@ -389,9 +389,8 @@ qeth_eddp_create_eddp_data(struct qeth_hstruct qeth_eddp_data *eddp;QETH_DBF_TEXT (trace,5 ,"eddpcrda" ); - eddp =kmalloc (sizeof (struct qeth_eddp_data ),GFP_ATOMIC ); + eddp =kzalloc (sizeof (struct qeth_eddp_data ),GFP_ATOMIC );if (eddp){ -memset (eddp,0 ,sizeof (struct qeth_eddp_data )); eddp->nhl = nhl; eddp->thl = thl;memcpy (&eddp->qh, qh,sizeof (struct qeth_hdr ));
@@ -542,12 +541,11 @@ qeth_eddp_create_context_generic(structQETH_DBF_TEXT (trace,5 ,"creddpcg" );/* create the context and allocate pages */ - ctx =kmalloc (sizeof (struct qeth_eddp_context ),GFP_ATOMIC ); + ctx =kzalloc (sizeof (struct qeth_eddp_context ),GFP_ATOMIC );if (ctx ==NULL ){QETH_DBF_TEXT (trace,2 ,"ceddpcn1" );return NULL ; } -memset (ctx,0 ,sizeof (struct qeth_eddp_context )); ctx->type =QETH_LARGE_SEND_EDDP ;qeth_eddp_calc_num_pages (ctx, skb, hdr_len);if (ctx->elements_per_skb >QETH_MAX_BUFFER_ELEMENTS (card)){
@@ -555,13 +553,12 @@ qeth_eddp_create_context_generic(structkfree (ctx);return NULL ; } - ctx->pages =kmalloc (ctx->num_pages *sizeof (u8 *),GFP_ATOMIC ); + ctx->pages =kcalloc (ctx->num_pages,sizeof (u8 *),GFP_ATOMIC );if (ctx->pages ==NULL ){QETH_DBF_TEXT (trace,2 ,"ceddpcn2" );kfree (ctx);return NULL ; } -memset (ctx->pages,0 , ctx->num_pages *sizeof (u8 *));for (i =0 ; i < ctx->num_pages; ++i){ addr = (u8 *)__get_free_page (GFP_ATOMIC );if (addr ==NULL ){
@@ -573,15 +570,13 @@ qeth_eddp_create_context_generic(structmemset (addr,0 ,PAGE_SIZE ); ctx->pages[i] = addr; } - ctx->elements =kmalloc (ctx->num_elements * + ctx->elements =kcalloc (ctx->num_elements,sizeof (struct qeth_eddp_element ),GFP_ATOMIC );if (ctx->elements ==NULL ){QETH_DBF_TEXT (trace,2 ,"ceddpcn4" );qeth_eddp_free_context (ctx);return NULL ; } -memset (ctx->elements,0 , - ctx->num_elements *sizeof (struct qeth_eddp_element ));/* reset num_elements; will be incremented again in fill_buffer to * reflect number of actually used elements */ ctx->num_elements =0 ;
drivers/s390/net/iucv.c renamed from drivers/s390/net/iucv.c.orig +4 -7
@@ -386,7 +386,7 @@ iucv_init(void) }/* Note: GFP_DMA used used to get memory below 2G */ - iucv_external_int_buffer =kmalloc (sizeof (iucv_GeneralInterrupt), + iucv_external_int_buffer =kzalloc (sizeof (iucv_GeneralInterrupt),GFP_KERNEL |GFP_DMA );if (!iucv_external_int_buffer) { printk(KERN_WARNING
@@ -396,10 +396,9 @@ iucv_init(void)bus_unregister (&iucv_bus);return -ENOMEM ; } -memset (iucv_external_int_buffer,0 ,sizeof (iucv_GeneralInterrupt));/* Initialize parameter pool */ - iucv_param_pool =kmalloc (sizeof (iucv_param) *PARAM_POOL_SIZE , + iucv_param_pool =kzalloc (sizeof (iucv_param) *PARAM_POOL_SIZE ,GFP_KERNEL |GFP_DMA );if (!iucv_param_pool) { printk(KERN_WARNING "%s: Could not allocate param pool\n",
@@ -410,7 +409,6 @@ iucv_init(void)bus_unregister (&iucv_bus);return -ENOMEM ; } -memset (iucv_param_pool,0 ,sizeof (iucv_param) *PARAM_POOL_SIZE );/* Initialize irq queue */ INIT_LIST_HEAD (&iucv_irq_queue);
@@ -793,15 +791,14 @@ iucv_register_program (__u8 pgmname[16], } max_connections =iucv_query_maxconn (); - iucv_pathid_table =kmalloc (max_connections *sizeof (handler *), -GFP_ATOMIC ); + iucv_pathid_table =kcalloc (max_connections,sizeof (handler *), +GFP_ATOMIC );if (iucv_pathid_table ==NULL ) {printk (KERN_WARNING "%s: iucv_pathid_table storage " "allocation failed\n" , __FUNCTION__);kfree (new_handler);return NULL ; } -memset (iucv_pathid_table,0 , max_connections *sizeof (handler *)); }memset (new_handler,0 ,sizeof (handler)); memcpy(new_handler->id.user_data, pgmname,
drivers/s390/net/netiucv.c renamed from drivers/s390/net/netiucv.c.orig +2 -5
@@ -1728,14 +1728,13 @@ static int netiucv_register_device(struct net_device *ndev) {struct netiucv_priv *priv = ndev->priv; -struct device *dev =kmalloc (sizeof (struct device ),GFP_KERNEL ); +struct device *dev =kzalloc (sizeof (struct device ),GFP_KERNEL );int ret;IUCV_DBF_TEXT (trace,3 , __FUNCTION__);if (dev) { -memset (dev,0 ,sizeof (struct device ));snprintf (dev->bus_id,BUS_ID_SIZE ,"net%s" , ndev->name); dev->bus = &iucv_bus; dev->parent = iucv_root;
@@ -1784,11 +1783,9 @@ netiucv_new_connection(struct net_device {struct iucv_connection **clist = &iucv_connections;struct iucv_connection *conn = - (struct iucv_connection *) -kmalloc (sizeof (struct iucv_connection ),GFP_KERNEL ); +kzalloc (sizeof (struct iucv_connection ),GFP_KERNEL );if (conn) { -memset (conn,0 ,sizeof (struct iucv_connection ));skb_queue_head_init (&conn->collect_queue);skb_queue_head_init (&conn->commit_queue); conn->max_buffsize =NETIUCV_BUFSIZE_DEFAULT ;
drivers/s390/block/dasd.c renamed from drivers/s390/block/dasd.c.orig +4 -8
@@ -73,10 +73,9 @@ dasd_alloc_device(void) {struct dasd_device *device; - device =kmalloc (sizeof (struct dasd_device ),GFP_ATOMIC ); + device =kzalloc (sizeof (struct dasd_device ),GFP_ATOMIC );if (device ==NULL )return ERR_PTR (-ENOMEM ); -memset (device,0 ,sizeof (struct dasd_device ));/* open_count = 0 means device online but not in use */ atomic_set (&device->open_count,-1 );
@@ -524,29 +523,26 @@ dasd_kmalloc_request(char *magic, int cp (cplength*sizeof(struct ccw1)) > PAGE_SIZE)BUG (); - cqr =kmalloc (sizeof (struct dasd_ccw_req ),GFP_ATOMIC ); + cqr =kzalloc (sizeof (struct dasd_ccw_req ),GFP_ATOMIC );if (cqr ==NULL )return ERR_PTR (-ENOMEM ); -memset (cqr,0 ,sizeof (struct dasd_ccw_req )); cqr->cpaddr =NULL ;if (cplength >0 ) { - cqr->cpaddr =kmalloc (cplength*sizeof (struct ccw1 ), + cqr->cpaddr =kcalloc (cplength,sizeof (struct ccw1 ),GFP_ATOMIC |GFP_DMA );if (cqr->cpaddr ==NULL ) {kfree (cqr);return ERR_PTR (-ENOMEM ); } -memset (cqr->cpaddr,0 , cplength*sizeof (struct ccw1 )); } cqr->data =NULL ;if (datasize >0 ) { - cqr->data =kmalloc (datasize,GFP_ATOMIC |GFP_DMA ); + cqr->data =kzalloc (datasize,GFP_ATOMIC |GFP_DMA );if (cqr->data ==NULL ) {kfree (cqr->cpaddr);kfree (cqr);return ERR_PTR (-ENOMEM ); } -memset (cqr->data,0 , datasize); }strncpy ((char *) &cqr->magic, magic,4 );ASCEBC ((char *) &cqr->magic,4 );
drivers/s390/block/dcssblk.c renamed from drivers/s390/block/dcssblk.c.orig +1 -2
@@ -388,12 +388,11 @@ dcssblk_add_store(struct device *dev, st/* * get a struct dcssblk_dev_info */ - dev_info =kmalloc (sizeof (struct dcssblk_dev_info ),GFP_KERNEL ); + dev_info =kzalloc (sizeof (struct dcssblk_dev_info ),GFP_KERNEL );if (dev_info ==NULL ) { rc = -ENOMEM ; goto out; } -memset (dev_info,0 ,sizeof (struct dcssblk_dev_info ));strcpy (dev_info->segment_name, local_buf);strlcpy (dev_info->dev.bus_id, local_buf,BUS_ID_SIZE );
drivers/s390/crypto/z90main.c renamed from drivers/s390/crypto/z90main.c.orig +3 -7
@@ -707,13 +707,12 @@ z90crypt_open(struct inode *inode, strucif (quiesce_z90crypt)return -EQUIESCE ; - private_data_p =kmalloc (sizeof (struct priv_data ),GFP_KERNEL ); + private_data_p =kzalloc (sizeof (struct priv_data ),GFP_KERNEL );if (!private_data_p) {PRINTK ("Memory allocate failed\n" );return -ENOMEM ; } -memset ((void *)private_data_p,0 ,sizeof (struct priv_data )); private_data_p->status =STAT_OPEN ; private_data_p->opener_pid =PID (); filp->private_data = private_data_p;
@@ -2736,13 +2735,11 @@ create_z90crypt(int *cdx_p) z90crypt.max_count =Z90CRYPT_NUM_DEVS ; z90crypt.cdx = *cdx_p; - hdware_blk_p = (struct hdware_block *) -kmalloc (sizeof (struct hdware_block ),GFP_ATOMIC ); + hdware_blk_p =kzalloc (sizeof (struct hdware_block ),GFP_ATOMIC );if (!hdware_blk_p) {PDEBUG ("kmalloc for hardware block failed\n" );return ENOMEM ; } -memset (hdware_blk_p,0x00 ,sizeof (struct hdware_block )); z90crypt.hdware_info = hdware_blk_p;return 0 ;
@@ -2977,12 +2974,11 @@ create_crypto_device(int index) total_size =sizeof (struct device ) + z90crypt.q_depth_array[index] *sizeof (int ); - dev_ptr = (struct device *)kmalloc (total_size,GFP_ATOMIC ); + dev_ptr =kzalloc (total_size,GFP_ATOMIC );if (!dev_ptr) {PRINTK ("kmalloc device %d failed\n" , index);return ENOMEM ; } -memset (dev_ptr,0 , total_size); dev_ptr->dev_resp_p =kmalloc (MAX_RESPONSE_SIZE ,GFP_ATOMIC );if (!dev_ptr->dev_resp_p) {kfree (dev_ptr);
drivers/s390/char/monreader.c renamed from drivers/s390/char/monreader.c.orig +2 -4
@@ -257,14 +257,13 @@ mon_alloc_mem(void)int i,j;struct mon_private *monpriv; - monpriv =kmalloc (sizeof (struct mon_private ),GFP_KERNEL ); + monpriv =kzalloc (sizeof (struct mon_private ),GFP_KERNEL );if (!monpriv) {P_ERROR ("no memory for monpriv\n" );return NULL ; } -memset (monpriv,0 ,sizeof (struct mon_private ));for (i =0 ; i <MON_MSGLIM ; i++) { - monpriv->msg_array[i] =kmalloc (sizeof (struct mon_msg ), + monpriv->msg_array[i] =kzalloc (sizeof (struct mon_msg ),GFP_KERNEL );if (!monpriv->msg_array[i]) {P_ERROR ("open, no memory for msg_array\n" );
@@ -272,7 +271,6 @@ mon_alloc_mem(void)kfree (monpriv->msg_array[j]);return NULL ; } -memset (monpriv->msg_array[i],0 ,sizeof (struct mon_msg )); }return monpriv; }
drivers/s390/char/raw3270.c renamed from drivers/s390/char/raw3270.c.orig +1 -2
@@ -115,10 +115,9 @@ raw3270_request_alloc(size_t size)struct raw3270_request *rq;/* Allocate request structure */ - rq =kmalloc (sizeof (struct raw3270_request ),GFP_KERNEL |GFP_DMA ); + rq =kzalloc (sizeof (struct raw3270_request ),GFP_KERNEL |GFP_DMA );if (!rq)return ERR_PTR (-ENOMEM ); -memset (rq,0 ,sizeof (struct raw3270_request ));/* alloc output buffer. */ if (size >0 ) {
drivers/s390/char/fs3270.c renamed from drivers/s390/char/fs3270.c.orig +1 -2
@@ -368,10 +368,9 @@ fs3270_alloc_view(void) {struct fs3270 *fp; - fp = (struct fs3270 *)kmalloc (sizeof (struct fs3270 ),GFP_KERNEL ); + fp =kzalloc (sizeof (struct fs3270 ),GFP_KERNEL );if (!fp)return ERR_PTR (-ENOMEM ); -memset (fp,0 ,sizeof (struct fs3270 )); fp->init =raw3270_request_alloc (0 );if (IS_ERR (fp->init)) {kfree (fp);
drivers/s390/char/tape_core.c renamed from drivers/s390/char/tape_core.c.orig +5 -11
@@ -453,16 +453,14 @@ tape_alloc_device(void) {struct tape_device *device; - device = (struct tape_device *) -kmalloc (sizeof (struct tape_device ),GFP_KERNEL ); + device =kzalloc (sizeof (struct tape_device ),GFP_KERNEL );if (device ==NULL ) {DBF_EXCEPTION (2 ,"ti:no mem\n" );PRINT_INFO ("can't allocate memory for " "tape info structure\n" );return ERR_PTR (-ENOMEM ); } -memset (device,0 ,sizeof (struct tape_device )); - device->modeset_byte = (char *)kmalloc (1 ,GFP_KERNEL |GFP_DMA ); + device->modeset_byte =kmalloc (1 ,GFP_KERNEL |GFP_DMA );if (device->modeset_byte ==NULL ) {DBF_EXCEPTION (2 ,"ti:no mem\n" );PRINT_INFO ("can't allocate memory for modeset byte\n" );
@@ -659,34 +657,30 @@ tape_alloc_request(int cplength, int datDBF_LH (6 ,"tape_alloc_request(%d, %d)\n" , cplength, datasize); - request = (struct tape_request *)kmalloc (sizeof (struct tape_request ), -GFP_KERNEL ); + request =kzalloc (sizeof (struct tape_request ),GFP_KERNEL );if (request ==NULL ) {DBF_EXCEPTION (1 ,"cqra nomem\n" );return ERR_PTR (-ENOMEM ); } -memset (request,0 ,sizeof (struct tape_request ));/* allocate channel program */ if (cplength >0 ) { - request->cpaddr =kmalloc (cplength*sizeof (struct ccw1 ), + request->cpaddr =kcalloc (cplength,sizeof (struct ccw1 ),GFP_ATOMIC |GFP_DMA );if (request->cpaddr ==NULL ) {DBF_EXCEPTION (1 ,"cqra nomem\n" );kfree (request);return ERR_PTR (-ENOMEM ); } -memset (request->cpaddr,0 , cplength*sizeof (struct ccw1 )); }/* alloc small kernel buffer */ if (datasize >0 ) { - request->cpdata =kmalloc (datasize,GFP_KERNEL |GFP_DMA ); + request->cpdata =kzalloc (datasize,GFP_KERNEL |GFP_DMA );if (request->cpdata ==NULL ) {DBF_EXCEPTION (1 ,"cqra nomem\n" );kfree (request->cpaddr);kfree (request);return ERR_PTR (-ENOMEM ); } -memset (request->cpdata,0 , datasize); }DBF_LH (6 ,"New request %p(%p/%p)\n" , request, request->cpaddr, request->cpdata);
drivers/s390/char/tape_class.c renamed from drivers/s390/char/tape_class.c.orig +1 -2
@@ -44,11 +44,10 @@ struct tape_class_device *register_tape_int rc;char * s; - tcd =kmalloc (sizeof (struct tape_class_device ),GFP_KERNEL ); + tcd =kzalloc (sizeof (struct tape_class_device ),GFP_KERNEL );if (!tcd)return ERR_PTR (-ENOMEM ); -memset (tcd,0 ,sizeof (struct tape_class_device ));strncpy (tcd->device_name, device_name,TAPECLASS_NAME_LEN );for (s =strchr (tcd->device_name,'/' ); s; s =strchr (s,'/' )) *s ='!' ;
drivers/s390/char/keyboard.c renamed from drivers/s390/char/keyboard.c.orig +4 -8
@@ -50,14 +50,12 @@ kbd_alloc(void) {struct kbd_data *kbd;int i, len; - kbd =kmalloc (sizeof (struct kbd_data ),GFP_KERNEL ); + kbd =kzalloc (sizeof (struct kbd_data ),GFP_KERNEL );if (!kbd) goto out; -memset (kbd,0 ,sizeof (struct kbd_data )); - kbd->key_maps =kmalloc (sizeof (key_maps),GFP_KERNEL ); + kbd->key_maps =kzalloc (sizeof (key_maps),GFP_KERNEL );if (!key_maps) goto out_kbd; -memset (kbd->key_maps,0 ,sizeof (key_maps));for (i =0 ; i <ARRAY_SIZE (key_maps); i++) {if (key_maps[i]) { kbd->key_maps[i] =
@@ -68,10 +66,9 @@ kbd_alloc(void) { sizeof(u_short)*NR_KEYS); } } - kbd->func_table =kmalloc (sizeof (func_table),GFP_KERNEL ); + kbd->func_table =kzalloc (sizeof (func_table),GFP_KERNEL );if (!kbd->func_table) goto out_maps; -memset (kbd->func_table,0 ,sizeof (func_table));for (i =0 ; i <ARRAY_SIZE (func_table); i++) {if (func_table[i]) { len =strlen (func_table[i]) +1 ;
@@ -82,10 +79,9 @@ kbd_alloc(void) { } } kbd->fn_handler = -kmalloc (sizeof (fn_handler_fn *) *NR_FN_HANDLER ,GFP_KERNEL ); +kzalloc (sizeof (fn_handler_fn *) *NR_FN_HANDLER ,GFP_KERNEL );if (!kbd->fn_handler) goto out_func; -memset (kbd->fn_handler,0 ,sizeof (fn_handler_fn *) *NR_FN_HANDLER ); kbd->accent_table =kmalloc (sizeof (struct kbdiacr )*MAX_DIACR ,GFP_KERNEL );if (!kbd->accent_table)
drivers/s390/char/vmlogrdr.c renamed from drivers/s390/char/vmlogrdr.c.orig +1 -2
@@ -759,9 +759,8 @@ vmlogrdr_register_device(struct vmlogrdrstruct device *dev;int ret; - dev =kmalloc (sizeof (struct device ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct device ),GFP_KERNEL );if (dev) { -memset (dev,0 ,sizeof (struct device ));snprintf (dev->bus_id,BUS_ID_SIZE ,"%s" , priv->internal_name); dev->bus = &iucv_bus;
drivers/s390/char/tty3270.c renamed from drivers/s390/char/tty3270.c.orig +3 -6
@@ -691,10 +691,9 @@ tty3270_alloc_view(void)struct tty3270 *tp;int pages; - tp =kmalloc (sizeof (struct tty3270 ),GFP_KERNEL ); + tp =kzalloc (sizeof (struct tty3270 ),GFP_KERNEL );if (!tp) goto out_err; -memset (tp,0 ,sizeof (struct tty3270 )); tp->freemem_pages =kmalloc (sizeof (void *) *TTY3270_STRING_PAGES ,GFP_KERNEL );if (!tp->freemem_pages)
@@ -767,16 +766,14 @@ tty3270_alloc_screen(struct tty3270 *tp)int lines; size =sizeof (struct tty3270_line ) * (tp->view.rows -2 ); - tp->screen =kmalloc (size,GFP_KERNEL ); + tp->screen =kzalloc (size,GFP_KERNEL );if (!tp->screen) goto out_err; -memset (tp->screen,0 , size);for (lines =0 ; lines < tp->view.rows -2 ; lines++) { size =sizeof (struct tty3270_cell ) * tp->view.cols; - tp->screen[lines].cells =kmalloc (size,GFP_KERNEL ); + tp->screen[lines].cells =kzalloc (size,GFP_KERNEL );if (!tp->screen[lines].cells) goto out_screen; -memset (tp->screen[lines].cells,0 , size); }return 0 ; out_screen:
drivers/s390/s390_rdev.c renamed from drivers/s390/s390_rdev.c.orig +1 -2
@@ -27,10 +27,9 @@ s390_root_dev_register(const char *name)if (!strlen (name))return ERR_PTR (-EINVAL ); - dev =kmalloc (sizeof (struct device ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct device ),GFP_KERNEL );if (!dev)return ERR_PTR (-ENOMEM ); -memset (dev,0 ,sizeof (struct device ));strncpy (dev->bus_id, name,min (strlen (name), (size_t )BUS_ID_SIZE )); dev->release = s390_root_dev_release; ret =device_register (dev);
drivers/s390/cio/chsc.c renamed from drivers/s390/cio/chsc.c.orig +1 -2
@@ -1016,10 +1016,9 @@ new_channel_path(int chpid)struct channel_path *chp;int ret; - chp =kmalloc (sizeof (struct channel_path ),GFP_KERNEL ); + chp =kzalloc (sizeof (struct channel_path ),GFP_KERNEL );if (!chp)return -ENOMEM ; -memset (chp,0 ,sizeof (struct channel_path ));/* fill in status, etc. */ chp->id = chpid;
drivers/s390/cio/qdio.c renamed from drivers/s390/cio/qdio.c.orig +7 -13
@@ -1677,16 +1677,14 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr,int result=-ENOMEM ;for (i=0 ;i<no_input_qs;i++) { - q=kmalloc (sizeof (struct qdio_q ),GFP_KERNEL ); + q=kzalloc (sizeof (struct qdio_q ),GFP_KERNEL );if (!q) {QDIO_PRINT_ERR ("kmalloc of q failed!\n" ); goto out; } -memset (q,0 ,sizeof (struct qdio_q )); - - q->slib=kmalloc (PAGE_SIZE ,GFP_KERNEL ); + q->slib =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!q->slib) {QDIO_PRINT_ERR ("kmalloc of slib failed!\n" ); goto out;
@@ -1696,14 +1694,12 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr, }for (i=0 ;i<no_output_qs;i++) { - q=kmalloc (sizeof (struct qdio_q ),GFP_KERNEL ); + q =kzalloc (sizeof (struct qdio_q ),GFP_KERNEL );if (!q) { goto out; } -memset (q,0 ,sizeof (struct qdio_q )); - q->slib=kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!q->slib) {QDIO_PRINT_ERR ("kmalloc of slib failed!\n" );
@@ -2975,7 +2971,7 @@ qdio_allocate(struct qdio_initialize *inqdio_allocate_do_dbf (init_data);/* create irq */ - irq_ptr=kmalloc (sizeof (struct qdio_irq ),GFP_KERNEL |GFP_DMA ); + irq_ptr =kzalloc (sizeof (struct qdio_irq ),GFP_KERNEL |GFP_DMA );QDIO_DBF_TEXT0 (0 ,setup,"irq_ptr:" );QDIO_DBF_HEX0 (0 ,setup,&irq_ptr,sizeof (void *));
@@ -2985,8 +2981,6 @@ qdio_allocate(struct qdio_initialize *inreturn -ENOMEM ; } -memset (irq_ptr,0 ,sizeof (struct qdio_irq )); -init_MUTEX (&irq_ptr->setting_up_sema);/* QDR must be in DMA area since CCW data address is only 32 bit */
@@ -3677,10 +3671,10 @@ qdio_get_qdio_memory(void)for (i=1 ;i<INDICATORS_PER_CACHELINE ;i++) indicator_used[i]=0 ; - indicators=(__u32 *)kmalloc (sizeof (__u32)*(INDICATORS_PER_CACHELINE ), + indicators =kzalloc (sizeof (__u32)*(INDICATORS_PER_CACHELINE ),GFP_KERNEL ); -if (!indicators)return -ENOMEM ; -memset (indicators,0 ,sizeof (__u32)*(INDICATORS_PER_CACHELINE )); +if (!indicators) +return -ENOMEM ;return 0 ; }
drivers/s390/cio/device.c renamed from drivers/s390/cio/device.c.orig +2 -4
@@ -826,17 +826,15 @@ io_subchannel_probe (struct subchannel *get_device (&cdev->dev);return 0 ; } - cdev =kmalloc (sizeof (*cdev),GFP_KERNEL ); + cdev =kzalloc (sizeof (*cdev),GFP_KERNEL );if (!cdev)return -ENOMEM ; -memset (cdev,0 ,sizeof (struct ccw_device )); - cdev->private =kmalloc (sizeof (struct ccw_device_private ), + cdev->private =kzalloc (sizeof (struct ccw_device_private ),GFP_KERNEL |GFP_DMA );if (!cdev->private) {kfree (cdev);return -ENOMEM ; } -memset (cdev->private,0 ,sizeof (struct ccw_device_private ));atomic_set (&cdev->private->onoff,0 ); cdev->dev = (struct device ) { .parent = &sch->dev,
drivers/s390/cio/device_ops.c renamed from drivers/s390/cio/device_ops.c.orig +3 -6
@@ -359,10 +359,9 @@ read_dev_chars (struct ccw_device *cdev,CIO_TRACE_EVENT (4 ,"rddevch" );CIO_TRACE_EVENT (4 , sch->dev.bus_id); - rdc_ccw =kmalloc (sizeof (struct ccw1 ),GFP_KERNEL |GFP_DMA ); + rdc_ccw =kzalloc (sizeof (struct ccw1 ),GFP_KERNEL |GFP_DMA );if (!rdc_ccw)return -ENOMEM ; -memset (rdc_ccw,0 ,sizeof (struct ccw1 )); rdc_ccw->cmd_code =CCW_CMD_RDC ; rdc_ccw->count = length; rdc_ccw->flags =CCW_FLAG_SLI ;
@@ -426,16 +425,14 @@ read_conf_data_lpm (struct ccw_device *cif (!ciw || ciw->cmd ==0 )return -EOPNOTSUPP ; - rcd_ccw =kmalloc (sizeof (struct ccw1 ),GFP_KERNEL |GFP_DMA ); + rcd_ccw =kzalloc (sizeof (struct ccw1 ),GFP_KERNEL |GFP_DMA );if (!rcd_ccw)return -ENOMEM ; -memset (rcd_ccw,0 ,sizeof (struct ccw1 )); - rcd_buf =kmalloc (ciw->count,GFP_KERNEL |GFP_DMA ); + rcd_buf =kzalloc (ciw->count,GFP_KERNEL |GFP_DMA );if (!rcd_buf) {kfree (rcd_ccw);return -ENOMEM ; } -memset (rcd_buf,0 , ciw->count); rcd_ccw->cmd_code = ciw->cmd; rcd_ccw->cda = (__u32 )__pa (rcd_buf); rcd_ccw->count = ciw->count;
drivers/s390/cio/css.c renamed from drivers/s390/cio/css.c.orig +1 -2
@@ -586,10 +586,9 @@ css_enqueue_subchannel_slow(struct subchstruct slow_subchannel *new_slow_sch;unsigned long flags; - new_slow_sch =kmalloc (sizeof (struct slow_subchannel ),GFP_ATOMIC ); + new_slow_sch =kzalloc (sizeof (struct slow_subchannel ),GFP_ATOMIC );if (!new_slow_sch)return -ENOMEM ; -memset (new_slow_sch,0 ,sizeof (struct slow_subchannel )); new_slow_sch->schid = schid;spin_lock_irqsave (&slow_subchannel_lock, flags);list_add_tail (&new_slow_sch->slow_list, &slow_subchannels_head);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/pci
In reply to Eric Sesterhennhi,
this patch converts drivers/pci to kzalloc usage.
Compile tested with allyes config.
drivers/pci/pcie/portdrv_core.c renamed from drivers/pci/pcie/portdrv_core.c.orig +1 -2
@@ -248,11 +248,10 @@ static struct pcie_device* alloc_pcie_de {struct pcie_device *device; - device =kmalloc (sizeof (struct pcie_device ),GFP_KERNEL ); + device =kzalloc (sizeof (struct pcie_device ),GFP_KERNEL );if (!device)return NULL ; -memset (device,0 ,sizeof (struct pcie_device ));pcie_device_init (parent, device, port_type, service_type, irq,irq_mode);printk (KERN_DEBUG "Allocate Port Service[%s]\n" , device->device.bus_id);return device;
drivers/pci/pci-sysfs.c renamed from drivers/pci/pci-sysfs.c.orig +1 -2
@@ -501,9 +501,8 @@ int pci_create_sysfs_dev_files (struct pif (pci_resource_len (pdev,PCI_ROM_RESOURCE )) {struct bin_attribute *rom_attr; - rom_attr =kmalloc (sizeof (*rom_attr),GFP_ATOMIC ); + rom_attr =kzalloc (sizeof (*rom_attr),GFP_ATOMIC );if (rom_attr) { -memset (rom_attr,0x00 ,sizeof (*rom_attr)); pdev->rom_attr = rom_attr; rom_attr->size =pci_resource_len (pdev,PCI_ROM_RESOURCE ); rom_attr->attr.name ="rom" ;
drivers/pci/pci-driver.c renamed from drivers/pci/pci-driver.c.orig +1 -2
@@ -53,11 +53,10 @@ store_new_id(struct device_driver *driveif (fields <0 )return -EINVAL ; - dynid =kmalloc (sizeof (*dynid),GFP_KERNEL ); + dynid =kzalloc (sizeof (*dynid),GFP_KERNEL );if (!dynid)return -ENOMEM ; -memset (dynid,0 ,sizeof (*dynid));INIT_LIST_HEAD (&dynid->node); dynid->id.vendor = vendor; dynid->id.device = device;
drivers/pci/probe.c renamed from drivers/pci/probe.c.orig +3 -6
@@ -33,10 +33,9 @@ LIST_HEAD(pci_devices);*/ static void pci_create_legacy_files (struct pci_bus *b) { - b->legacy_io =kmalloc (sizeof (struct bin_attribute ) *2 , + b->legacy_io =kzalloc (sizeof (struct bin_attribute ) *2 ,GFP_ATOMIC );if (b->legacy_io) { -memset (b->legacy_io,0 ,sizeof (struct bin_attribute ) *2 ); b->legacy_io->attr.name ="legacy_io" ; b->legacy_io->size =0xffff ; b->legacy_io->attr.mode =S_IRUSR |S_IWUSR ;
@@ -320,9 +319,8 @@ static struct pci_bus * __devinit pci_al {struct pci_bus *b; - b =kmalloc (sizeof (*b),GFP_KERNEL ); + b =kzalloc (sizeof (*b),GFP_KERNEL );if (b) { -memset (b,0 ,sizeof (*b));INIT_LIST_HEAD (&b->node);INIT_LIST_HEAD (&b->children);INIT_LIST_HEAD (&b->devices);
@@ -797,11 +795,10 @@ pci_scan_device(struct pci_bus *bus, intif (pci_bus_read_config_byte (bus, devfn,PCI_HEADER_TYPE , &hdr_type))return NULL ; - dev =kmalloc (sizeof (struct pci_dev ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct pci_dev ),GFP_KERNEL );if (!dev)return NULL ; -memset (dev,0 ,sizeof (struct pci_dev )); dev->bus = bus; dev->sysdata = bus->sysdata; dev->dev.parent = bus->bridge;
drivers/pci/hotplug/ibmphp_ebda.c renamed from drivers/pci/hotplug/ibmphp_ebda.c.orig +14 -43
155 lines not on this page · raw message
drivers/pci/hotplug/pciehp_core.c renamed from drivers/pci/hotplug/pciehp_core.c.orig +4 -9
@@ -117,27 +117,23 @@ static int init_slots(struct controller slot_number = ctrl->first_slot;while (number_of_slots) { - slot =kmalloc (sizeof (*slot),GFP_KERNEL ); + slot =kzalloc (sizeof (*slot),GFP_KERNEL );if (!slot) goto error; -memset (slot,0 ,sizeof (struct slot )); slot->hotplug_slot = -kmalloc (sizeof (*(slot->hotplug_slot)), +kzalloc (sizeof (*(slot->hotplug_slot)),GFP_KERNEL );if (!slot->hotplug_slot) goto error_slot; hotplug_slot = slot->hotplug_slot; -memset (hotplug_slot,0 ,sizeof (struct hotplug_slot )); hotplug_slot->info = -kmalloc (sizeof (*(hotplug_slot->info)), +kzalloc (sizeof (*(hotplug_slot->info)),GFP_KERNEL );if (!hotplug_slot->info) goto error_hpslot; hotplug_slot_info = hotplug_slot->info; -memset (hotplug_slot_info,0 , -sizeof (struct hotplug_slot_info )); hotplug_slot->name =kmalloc (SLOT_NAME_SIZE ,GFP_KERNEL );if (!hotplug_slot->name) goto error_info;
@@ -373,12 +369,11 @@ static int pciehp_probe(struct pcie_deviu8 value;struct pci_dev *pdev; - ctrl =kmalloc (sizeof (*ctrl),GFP_KERNEL ); + ctrl =kzalloc (sizeof (*ctrl),GFP_KERNEL );if (!ctrl) {err ("%s : out of memory\n" , __FUNCTION__); goto err_out_none; } -memset (ctrl,0 ,sizeof (struct controller )); pdev = dev->port; ctrl->pci_dev = pdev;
drivers/pci/hotplug/cpqphp_core.c renamed from drivers/pci/hotplug/cpqphp_core.c.orig +4 -9
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct contro slot_number = ctrl->first_slot;while (number_of_slots) { - slot =kmalloc (sizeof (*slot),GFP_KERNEL ); + slot =kzalloc (sizeof (*slot),GFP_KERNEL );if (!slot) goto error; -memset (slot,0 ,sizeof (struct slot )); - slot->hotplug_slot =kmalloc (sizeof (*(slot->hotplug_slot)), + slot->hotplug_slot =kzalloc (sizeof (*(slot->hotplug_slot)),GFP_KERNEL );if (!slot->hotplug_slot) goto error_slot; hotplug_slot = slot->hotplug_slot; -memset (hotplug_slot,0 ,sizeof (struct hotplug_slot )); hotplug_slot->info = -kmalloc (sizeof (*(hotplug_slot->info)), +kzalloc (sizeof (*(hotplug_slot->info)),GFP_KERNEL );if (!hotplug_slot->info) goto error_hpslot; hotplug_slot_info = hotplug_slot->info; -memset (hotplug_slot_info,0 , -sizeof (struct hotplug_slot_info )); hotplug_slot->name =kmalloc (SLOT_NAME_SIZE ,GFP_KERNEL );if (!hotplug_slot->name)
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev * goto err_disable_device; } - ctrl = (struct controller *)kmalloc (sizeof (struct controller ),GFP_KERNEL ); + ctrl =kzalloc (sizeof (struct controller ),GFP_KERNEL );if (!ctrl) {err ("%s : out of memory\n" , __FUNCTION__); rc = -ENOMEM ; goto err_disable_device; } -memset (ctrl,0 ,sizeof (struct controller )); rc =pci_read_config_word (pdev,PCI_SUBSYSTEM_ID , &subsystem_deviceid);if (rc) {
drivers/pci/hotplug/cpci_hotplug_core.c renamed from drivers/pci/hotplug/cpci_hotplug_core.c.orig +3 -6
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus* with the pci_hotplug subsystem. */ for (i = first; i <= last; ++i) { - slot =kmalloc (sizeof (struct slot ),GFP_KERNEL ); + slot =kzalloc (sizeof (struct slot ),GFP_KERNEL );if (!slot) goto error; -memset (slot,0 ,sizeof (struct slot )); hotplug_slot = -kmalloc (sizeof (struct hotplug_slot ),GFP_KERNEL ); +kzalloc (sizeof (struct hotplug_slot ),GFP_KERNEL );if (!hotplug_slot) goto error_slot; -memset (hotplug_slot,0 ,sizeof (struct hotplug_slot )); slot->hotplug_slot = hotplug_slot; - info =kmalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL );if (!info) goto error_hpslot; -memset (info,0 ,sizeof (struct hotplug_slot_info )); hotplug_slot->info = info; name =kmalloc (SLOT_NAME_SIZE ,GFP_KERNEL );
drivers/pci/hotplug/ibmphp_core.c renamed from drivers/pci/hotplug/ibmphp_core.c.orig +2 -4
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_sl goto error_power; } - slot_cur->func =kmalloc (sizeof (struct pci_func ),GFP_KERNEL ); + slot_cur->func =kzalloc (sizeof (struct pci_func ),GFP_KERNEL );if (!slot_cur->func) {/* We cannot do update_slot_info here, since no memory for * kmalloc n.e.ways, and update_slot_info allocates some */
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_sl rc = -ENOMEM ; goto error_power; } -memset (slot_cur->func,0 ,sizeof (struct pci_func )); slot_cur->func->busno = slot_cur->bus; slot_cur->func->device = slot_cur->device;for (i =0 ; i <4 ; i++)
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *if (slot_cur->func ==NULL ) {/* We need this for fncs's that were there on bootup */ - slot_cur->func =kmalloc (sizeof (struct pci_func ),GFP_KERNEL ); + slot_cur->func =kzalloc (sizeof (struct pci_func ),GFP_KERNEL );if (!slot_cur->func) {err ("out of system memory\n" ); rc = -ENOMEM ; goto error; } -memset (slot_cur->func,0 ,sizeof (struct pci_func )); slot_cur->func->busno = slot_cur->bus; slot_cur->func->device = slot_cur->device; }
drivers/pci/hotplug/rpaphp_slot.c renamed from drivers/pci/hotplug/rpaphp_slot.c.orig +3 -6
@@ -84,19 +84,16 @@ struct slot *alloc_slot_struct(struct de {struct slot *slot; - slot =kmalloc (sizeof (struct slot ),GFP_KERNEL ); + slot =kzalloc (sizeof (struct slot ),GFP_KERNEL );if (!slot) goto error_nomem; -memset (slot,0 ,sizeof (struct slot )); - slot->hotplug_slot =kmalloc (sizeof (struct hotplug_slot ),GFP_KERNEL ); + slot->hotplug_slot =kzalloc (sizeof (struct hotplug_slot ),GFP_KERNEL );if (!slot->hotplug_slot) goto error_slot; -memset (slot->hotplug_slot,0 ,sizeof (struct hotplug_slot )); - slot->hotplug_slot->info =kmalloc (sizeof (struct hotplug_slot_info ), + slot->hotplug_slot->info =kzalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL );if (!slot->hotplug_slot->info) goto error_hpslot; -memset (slot->hotplug_slot->info,0 ,sizeof (struct hotplug_slot_info )); slot->hotplug_slot->name =kmalloc (BUS_ID_SIZE +1 ,GFP_KERNEL );if (!slot->hotplug_slot->name) goto error_info;
drivers/pci/hotplug/ibmphp_res.c renamed from drivers/pci/hotplug/ibmphp_res.c.orig +11 -22
@@ -55,13 +55,12 @@ static struct bus_node * __init alloc_erreturn NULL ; } - newbus =kmalloc (sizeof (struct bus_node ),GFP_KERNEL ); + newbus =kzalloc (sizeof (struct bus_node ),GFP_KERNEL );if (!newbus) {err ("out of system memory\n" );return NULL ; } -memset (newbus,0 ,sizeof (struct bus_node ));if (flag) newbus->busno = busno;else
@@ -79,12 +78,11 @@ static struct resource_node * __init allreturn NULL ; } - rs =kmalloc (sizeof (struct resource_node ),GFP_KERNEL ); + rs =kzalloc (sizeof (struct resource_node ),GFP_KERNEL );if (!rs) {err ("out of system memory\n" );return NULL ; } -memset (rs,0 ,sizeof (struct resource_node )); rs->busno = curr->bus_num; rs->devfunc = curr->dev_fun; rs->start = curr->start_addr;
@@ -100,12 +98,11 @@ static int __init alloc_bus_range (strucu8 num_ranges =0 ;if (first_bus) { - newbus =kmalloc (sizeof (struct bus_node ),GFP_KERNEL ); + newbus =kzalloc (sizeof (struct bus_node ),GFP_KERNEL );if (!newbus) {err ("out of system memory.\n" );return -ENOMEM ; } -memset (newbus,0 ,sizeof (struct bus_node )); newbus->busno = curr->bus_num; }else { newbus = *new_bus;
@@ -122,14 +119,13 @@ static int __init alloc_bus_range (struc } } - newrange =kmalloc (sizeof (struct range_node ),GFP_KERNEL ); + newrange =kzalloc (sizeof (struct range_node ),GFP_KERNEL );if (!newrange) {if (first_bus)kfree (newbus);err ("out of system memory\n" );return -ENOMEM ; } -memset (newrange,0 ,sizeof (struct range_node )); newrange->start = curr->start_addr; newrange->end = curr->end_addr;
@@ -1705,12 +1701,11 @@ static int __init once_over (void) bus_cur->firstPFMemFromMem = pfmem_cur; - mem =kmalloc (sizeof (struct resource_node ),GFP_KERNEL ); + mem =kzalloc (sizeof (struct resource_node ),GFP_KERNEL );if (!mem) {err ("out of system memory\n" );return -ENOMEM ; } -memset (mem,0 ,sizeof (struct resource_node )); mem->type =MEM ; mem->busno = pfmem_cur->busno; mem->devfunc = pfmem_cur->devfunc;
@@ -1994,12 +1989,11 @@ static int __init update_bridge_ranges ( end_address |= (upper_io_end <<16 );if ((start_address) && (start_address <= end_address)) { - range =kmalloc (sizeof (struct range_node ),GFP_KERNEL ); + range =kzalloc (sizeof (struct range_node ),GFP_KERNEL );if (!range) {err ("out of system memory\n" );return -ENOMEM ; } -memset (range,0 ,sizeof (struct range_node )); range->start = start_address; range->end = end_address +0xfff ;
@@ -2020,13 +2014,12 @@ static int __init update_bridge_ranges (fix_resources (bus_sec);if (ibmphp_find_resource (bus_cur, start_address, &io,IO )) { - io =kmalloc (sizeof (struct resource_node ),GFP_KERNEL ); + io =kzalloc (sizeof (struct resource_node ),GFP_KERNEL );if (!io) {kfree (range);err ("out of system memory\n" );return -ENOMEM ; } -memset (io,0 ,sizeof (struct resource_node )); io->type =IO ; io->busno = bus_cur->busno; io->devfunc = ((device <<3 ) | (function &0x7 ));
@@ -2045,12 +2038,11 @@ static int __init update_bridge_ranges (if ((start_address) && (start_address <= end_address)) { - range =kmalloc (sizeof (struct range_node ),GFP_KERNEL ); + range =kzalloc (sizeof (struct range_node ),GFP_KERNEL );if (!range) {err ("out of system memory\n" );return -ENOMEM ; } -memset (range,0 ,sizeof (struct range_node )); range->start = start_address; range->end = end_address +0xfffff ;
@@ -2072,13 +2064,12 @@ static int __init update_bridge_ranges (fix_resources (bus_sec);if (ibmphp_find_resource (bus_cur, start_address, &mem,MEM )) { - mem =kmalloc (sizeof (struct resource_node ),GFP_KERNEL ); + mem =kzalloc (sizeof (struct resource_node ),GFP_KERNEL );if (!mem) {kfree (range);err ("out of system memory\n" );return -ENOMEM ; } -memset (mem,0 ,sizeof (struct resource_node )); mem->type =MEM ; mem->busno = bus_cur->busno; mem->devfunc = ((device <<3 ) | (function &0x7 ));
@@ -2101,12 +2092,11 @@ static int __init update_bridge_ranges (if ((start_address) && (start_address <= end_address)) { - range =kmalloc (sizeof (struct range_node ),GFP_KERNEL ); + range =kzalloc (sizeof (struct range_node ),GFP_KERNEL );if (!range) {err ("out of system memory\n" );return -ENOMEM ; } -memset (range,0 ,sizeof (struct range_node )); range->start = start_address; range->end = end_address +0xfffff ;
@@ -2127,13 +2117,12 @@ static int __init update_bridge_ranges (fix_resources (bus_sec);if (ibmphp_find_resource (bus_cur, start_address, &pfmem,PFMEM )) { - pfmem =kmalloc (sizeof (struct resource_node ),GFP_KERNEL ); + pfmem =kzalloc (sizeof (struct resource_node ),GFP_KERNEL );if (!pfmem) {kfree (range);err ("out of system memory\n" );return -ENOMEM ; } -memset (pfmem,0 ,sizeof (struct resource_node )); pfmem->type =PFMEM ; pfmem->busno = bus_cur->busno; pfmem->devfunc = ((device <<3 ) | (function &0x7 ));
drivers/pci/hotplug/acpiphp_glue.c renamed from drivers/pci/hotplug/acpiphp_glue.c.orig +4 -10
@@ -143,10 +143,9 @@ register_slot(acpi_handle handle, u32 lv device = (adr >>16 ) &0xffff ; function = adr &0xffff ; - newfunc =kmalloc (sizeof (struct acpiphp_func ),GFP_KERNEL ); + newfunc =kzalloc (sizeof (struct acpiphp_func ),GFP_KERNEL );if (!newfunc)return AE_NO_MEMORY ; -memset (newfunc,0 ,sizeof (struct acpiphp_func ));INIT_LIST_HEAD (&newfunc->sibling); newfunc->handle = handle;
@@ -189,13 +188,12 @@ register_slot(acpi_handle handle, u32 lv }if (!slot) { - slot =kmalloc (sizeof (struct acpiphp_slot ),GFP_KERNEL ); + slot =kzalloc (sizeof (struct acpiphp_slot ),GFP_KERNEL );if (!slot) {kfree (newfunc);return AE_NO_MEMORY ; } -memset (slot,0 ,sizeof (struct acpiphp_slot )); slot->bridge = bridge; slot->device = device; slot->sun = sun;
@@ -376,12 +374,10 @@ static void add_host_bridge(acpi_handle {struct acpiphp_bridge *bridge; - bridge =kmalloc (sizeof (struct acpiphp_bridge ),GFP_KERNEL ); + bridge =kzalloc (sizeof (struct acpiphp_bridge ),GFP_KERNEL );if (bridge ==NULL )return ; -memset (bridge,0 ,sizeof (struct acpiphp_bridge )); - bridge->type =BRIDGE_TYPE_HOST ; bridge->handle = handle;
@@ -398,14 +394,12 @@ static void add_p2p_bridge(acpi_handle * {struct acpiphp_bridge *bridge; - bridge =kmalloc (sizeof (struct acpiphp_bridge ),GFP_KERNEL ); + bridge =kzalloc (sizeof (struct acpiphp_bridge ),GFP_KERNEL );if (bridge ==NULL ) {err ("out of memory\n" );return ; } -memset (bridge,0 ,sizeof (struct acpiphp_bridge )); - bridge->type =BRIDGE_TYPE_P2P ; bridge->handle = handle;
drivers/pci/hotplug/ibmphp_pci.c renamed from drivers/pci/hotplug/ibmphp_pci.c.orig +21 -42
284 lines not on this page · raw message
drivers/pci/hotplug/fakephp.c renamed from drivers/pci/hotplug/fakephp.c.orig +3 -6
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev)struct hotplug_slot *slot;int retval = -ENOMEM ; - slot =kmalloc (sizeof (struct hotplug_slot ),GFP_KERNEL ); + slot =kzalloc (sizeof (struct hotplug_slot ),GFP_KERNEL );if (!slot) goto error; -memset (slot,0 ,sizeof (*slot)); - slot->info =kmalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL ); + slot->info =kzalloc (sizeof (struct hotplug_slot_info ),GFP_KERNEL );if (!slot->info) goto error_slot; -memset (slot->info,0 ,sizeof (struct hotplug_slot_info )); slot->info->power_status =1 ; slot->info->max_bus_speed =PCI_SPEED_UNKNOWN ;
@@ -227,11 +225,10 @@ static void pci_rescan_bus(const struct {unsigned int devfn;struct pci_dev *dev; - dev =kmalloc (sizeof (struct pci_dev ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct pci_dev ),GFP_KERNEL );if (!dev)return ; -memset (dev,0 ,sizeof (dev)); dev->bus = (struct pci_bus *)bus; dev->sysdata = bus->sysdata;for (devfn =0 ; devfn <0x100 ; devfn +=8 ) {
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
In reply to Eric SesterhennQuoted 10 lines · Jesper Juhl
Quoted 7 lines · Eric Sesterhenn
this patch converts
drivers/usbto kzalloc usage. Compile tested with allyes config.I think there was a bug in
drivers/usb/gadget/inode.cbecause it usedsizeof(*data)for thekmalloc()and sizeof(data) for thememset(), since sizeof(data) just returns the size for a pointer.I don't know this code well, but looking briefly at it I'd say your analysis is correct and your patch fixes that bug.
That's what kernel janitors are for. Looking above and below mostly trivial changes, noticing suspicious things.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [Patch] kzalloc() conversion in drivers/usb/gadget
In reply to Eric SesterhennQuoted 9 lines · Alexey Dobriyan
Quoted 8 lines · Jesper Juhl
Quoted 7 lines · Eric Sesterhenn
this patch converts
drivers/usbto kzalloc usage. Compile tested with allyes config.I think there was a bug in
drivers/usb/gadget/inode.cbecause it usedsizeof(*data)for thekmalloc()and sizeof(data) for thememset(), since sizeof(data) just returns the size for a pointer.
Quoted 6 lines
Quoted 2 lines
I don't know this code well, but looking briefly at it I'd say your analysis is correct and your patch fixes that bug.
That's what kernel janitors are for. Looking above and below mostly trivial changes, noticing suspicious things.
Yes, and that's exactely why I geve Eric some feedback when I had read his patch. To let him know that at least one other person had looked at the work he had done and thought it looked good.
I'm sorry, but I don't really know what the intention of your comment was...?
--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/char
In reply to Eric Sesterhennhi,
this patch converts drivers/pci to kzalloc usage. Compile tested with allyes config.
char/rio/rio_linux.c and char/sx.c had a ckmalloc() function, which i removed and changed the callers to kzalloc().
zft_kmalloc() in char/ftape/zftape/zftape-buffers.c seems a bit strange to me, since it never returns, when it cant get memory allocated.
drivers/char/ftape/lowlevel/ftape-buffer.c renamed from drivers/char/ftape/lowlevel/ftape-buffer.c.orig +1 -2
@@ -74,11 +74,10 @@ static int add_one_buffer(void)if (ft_nr_buffers >=FT_MAX_NR_BUFFERS ) {TRACE_EXIT -ENOMEM ; } - ft_buffer[ft_nr_buffers] =kmalloc (sizeof (buffer_struct),GFP_KERNEL ); + ft_buffer[ft_nr_buffers] =kzalloc (sizeof (buffer_struct),GFP_KERNEL );if (ft_buffer[ft_nr_buffers] ==NULL ) {TRACE_EXIT -ENOMEM ; } -memset (ft_buffer[ft_nr_buffers],0 ,sizeof (buffer_struct)); ft_buffer[ft_nr_buffers]->address =dmaalloc (FT_BUFF_SIZE );if (ft_buffer[ft_nr_buffers]->address ==NULL ) {kfree (ft_buffer[ft_nr_buffers]);
drivers/char/ftape/zftape/zftape-buffers.c renamed from drivers/char/ftape/zftape/zftape-buffers.c.orig +1 -2
@@ -112,10 +112,9 @@ void *zft_kmalloc(size_t size) {void *new; -while ((new =kmalloc (size,GFP_KERNEL )) ==NULL ) { +while ((new =kzalloc (size,GFP_KERNEL )) ==NULL ) {msleep_interruptible (100 ); } -memset (new,0 , size); used_memory += size;if (peak_memory < used_memory) { peak_memory = used_memory;
drivers/char/hvcs.c renamed from drivers/char/hvcs.c.orig +1 -4
@@ -623,13 +623,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 */ kobject_init (&hvcsd->kobj);
drivers/char/hvc_console.c renamed from drivers/char/hvc_console.c.orig +1 -3
@@ -744,12 +744,10 @@ struct hvc_struct __devinit *hvc_alloc(ustruct hvc_struct *hp;int i; - hp =kmalloc (sizeof (*hp),GFP_KERNEL ); + hp =kzalloc (sizeof (*hp),GFP_KERNEL );if (!hp)return ERR_PTR (-ENOMEM ); -memset (hp,0x00 ,sizeof (*hp)); - hp->vtermno = vtermno; hp->irq = irq; hp->ops = ops;
drivers/char/tty_io.c renamed from drivers/char/tty_io.c.orig +5 -16
@@ -158,12 +158,7 @@ static void release_mem(struct tty_strucstatic struct tty_struct *alloc_tty_struct (void ) { -struct tty_struct *tty; - - tty =kmalloc (sizeof (struct tty_struct ),GFP_KERNEL ); -if (tty) -memset (tty,0 ,sizeof (struct tty_struct )); -return tty; +return kzalloc (sizeof (struct tty_struct ),GFP_KERNEL ); }static void tty_buffer_free_all (struct tty_struct *);
@@ -1506,11 +1501,9 @@ static int init_dev(struct tty_driver *d }if (!*ltp_loc) { - ltp = (struct termios *)kmalloc (sizeof (struct termios ), -GFP_KERNEL ); + ltp =kzalloc (sizeof (struct termios ),GFP_KERNEL );if (!ltp) goto free_mem_out; -memset (ltp,0 ,sizeof (struct termios )); }if (driver->type ==TTY_DRIVER_TYPE_PTY ) {
@@ -1539,11 +1532,9 @@ static int init_dev(struct tty_driver *d }if (!*o_ltp_loc) { - o_ltp = (struct termios *) -kmalloc (sizeof (struct termios ),GFP_KERNEL ); + o_ltp =kzalloc (sizeof (struct termios ),GFP_KERNEL );if (!o_ltp) goto free_mem_out; -memset (o_ltp,0 ,sizeof (struct termios )); }/*
@@ -2997,9 +2988,8 @@ struct tty_driver *alloc_tty_driver(int {struct tty_driver *driver; - driver =kmalloc (sizeof (struct tty_driver ),GFP_KERNEL ); + driver =kzalloc (sizeof (struct tty_driver ),GFP_KERNEL );if (driver) { -memset (driver,0 ,sizeof (struct tty_driver )); driver->magic =TTY_DRIVER_MAGIC ; driver->num = lines;/* later we'll move allocation of tables here */
@@ -3058,10 +3048,9 @@ int tty_register_driver(struct tty_drivereturn 0 ;if (!(driver->flags &TTY_DRIVER_DEVPTS_MEM )) { - p =kmalloc (driver->num *3 *sizeof (void *),GFP_KERNEL ); + p =kcalloc (driver->num,3 *sizeof (void *),GFP_KERNEL );if (!p)return -ENOMEM ; -memset (p,0 , driver->num *3 *sizeof (void *)); }if (!driver->major) {
drivers/char/ipmi/ipmi_si_intf.c renamed from drivers/char/ipmi/ipmi_si_intf.c.orig +5 -10
@@ -1242,12 +1242,11 @@ static int try_init_port(int intf_num, s ports[intf_num]))return -ENODEV ; - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info) {printk (KERN_ERR "ipmi_si: Could not allocate SI data (1)\n" );return -ENOMEM ; } -memset (info,0 ,sizeof (*info)); info->io_setup = port_setup; info->io.info = &(ports[intf_num]);
@@ -1403,12 +1402,11 @@ static int try_init_mem(int intf_num, st addrs[intf_num]))return -ENODEV ; - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info) {printk (KERN_ERR "ipmi_si: Could not allocate SI data (2)\n" );return -ENOMEM ; } -memset (info,0 ,sizeof (*info)); info->io_setup = mem_setup; info->io.info = &addrs[intf_num];
@@ -1602,12 +1600,11 @@ static int try_init_acpi(int intf_num, sreturn -EIO ; } - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info) {printk (KERN_ERR "ipmi_si: Could not allocate SI data (3)\n" );return -ENOMEM ; } -memset (info,0 ,sizeof (*info));if (spmi->InterruptType &1 ) {/* We've got a GPE interrupt. */
@@ -1780,12 +1777,11 @@ static int try_init_smbios(int intf_num,return -EIO ; } - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info) {printk (KERN_ERR "ipmi_si: Could not allocate SI data (4)\n" );return -ENOMEM ; } -memset (info,0 ,sizeof (*info));if (ipmi_data->addr_space ==1 ) { io_type ="memory" ;
@@ -1886,13 +1882,12 @@ static int find_pci_smic(int intf_num, sreturn -ENODEV ; } - info =kmalloc (sizeof (*info),GFP_KERNEL ); + info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info) {pci_dev_put (pci_dev);printk (KERN_ERR "ipmi_si: Could not allocate SI data (5)\n" );return -ENOMEM ; } -memset (info,0 ,sizeof (*info)); info->io_setup = port_setup; ports[intf_num] = base_addr;
drivers/char/ipmi/ipmi_msghandler.c renamed from drivers/char/ipmi/ipmi_msghandler.c.orig +1 -2
@@ -1825,10 +1825,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->intf_num =-1 ;kref_init (&intf->refcount); intf->version_major = version_major;
drivers/char/amiserial.c renamed from drivers/char/amiserial.c.orig +1 -2
@@ -1742,12 +1742,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/random.c renamed from drivers/char/random.c.orig +4 -8
@@ -912,11 +912,9 @@ void rand_initialize_irq(int irq)* If kmalloc returns null, we just won't use that entropy * source. */ - state =kmalloc (sizeof (struct timer_rand_state ),GFP_KERNEL ); -if (state) { -memset (state,0 ,sizeof (struct timer_rand_state )); + state =kzalloc (sizeof (struct timer_rand_state ),GFP_KERNEL ); +if (state) irq_timer_state[irq] = state; - } }void rand_initialize_disk (struct gendisk *disk)
@@ -927,11 +925,9 @@ void rand_initialize_disk(struct gendisk* If kmalloc returns null, we just won't use that entropy * source. */ - state =kmalloc (sizeof (struct timer_rand_state ),GFP_KERNEL ); -if (state) { -memset (state,0 ,sizeof (struct timer_rand_state )); + state =kzalloc (sizeof (struct timer_rand_state ),GFP_KERNEL ); +if (state) disk->random = state; - } } static ssize_t
drivers/char/consolemap.c renamed from drivers/char/consolemap.c.orig +3 -5
@@ -193,11 +193,10 @@ static void set_inverse_transl(struct vc q = p->inverse_translations[i];if (!q) { - q = p->inverse_translations[i] = (unsigned char *) -kmalloc (MAX_GLYPH ,GFP_KERNEL ); + q = p->inverse_translations[i] = +kzalloc (MAX_GLYPH ,GFP_KERNEL );if (!q)return ; } -memset (q,0 ,MAX_GLYPH );for (j =0 ; j <E_TABSZ ; j++) { glyph =conv_uni_to_pc (conp, t[j]);
@@ -444,12 +443,11 @@ int con_clear_unimap(struct vc_data *vc, p = (struct uni_pagedir *)*vc->vc_uni_pagedir_loc;if (p && p->readonly)return -EIO ;if (!p || --p->refcount) { - q = (struct uni_pagedir *)kmalloc (sizeof (*p),GFP_KERNEL ); + q =kzalloc (sizeof (*p),GFP_KERNEL );if (!q) {if (p) p->refcount++;return -ENOMEM ; } -memset (q,0 ,sizeof (*q)); q->refcount=1 ; *vc->vc_uni_pagedir_loc = (unsigned long )q; }else {
drivers/char/rio/rio_linux.c renamed from drivers/char/rio/rio_linux.c.orig +4 -17
@@ -844,19 +844,6 @@ static int rio_init_drivers(void)return 1 ; } - -static void *ckmalloc (int size) -{ -void *p; - - p =kmalloc (size,GFP_KERNEL ); -if (p) -memset (p,0 , size); -return p; -} - - -static int rio_init_datastructures (void ) {int i;
@@ -875,18 +862,18 @@ static int rio_init_datastructures(void)#define TMIO_SZ sizeof(struct termios *)rio_dprintk (RIO_DEBUG_INIT ,"getting : %d %d %d %d %d bytes\n" ,RI_SZ ,RIO_HOSTS *HOST_SZ ,RIO_PORTS *PORT_SZ ,RIO_PORTS *TMIO_SZ ,RIO_PORTS *TMIO_SZ ); -if (!(p =ckmalloc (RI_SZ ))) +if (!(p =kzalloc (RI_SZ ,GFP_KERNEL ))) goto free0; -if (!(p->RIOHosts =ckmalloc (RIO_HOSTS *HOST_SZ ))) +if (!(p->RIOHosts =kzalloc (RIO_HOSTS *HOST_SZ ,GFP_KERNEL ))) goto free1; -if (!(p->RIOPortp =ckmalloc (RIO_PORTS *PORT_SZ ))) +if (!(p->RIOPortp =kzalloc (RIO_PORTS *PORT_SZ ,GFP_KERNEL ))) goto free2; p->RIOConf = RIOConf;rio_dprintk (RIO_DEBUG_INIT ,"Got : %p %p %p\n" , p, p->RIOHosts, p->RIOPortp);#if 1 for (i =0 ; i <RIO_PORTS ; i++) { - port = p->RIOPortp[i] =ckmalloc (sizeof (struct Port )); + port = p->RIOPortp[i] =kzalloc (sizeof (struct Port ),GFP_KERNEL );if (!port) { goto free6; }
drivers/char/watchdog/pcwd_usb.c renamed from drivers/char/watchdog/pcwd_usb.c.orig +1 -2
@@ -597,12 +597,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/char/watchdog/mpcore_wdt.c renamed from drivers/char/watchdog/mpcore_wdt.c.orig +1 -2
@@ -329,12 +329,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/rocket.c renamed from drivers/char/rocket.c.orig +1 -2
@@ -654,12 +654,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/n_hdlc.c renamed from drivers/char/n_hdlc.c.orig +1 -3
@@ -802,13 +802,11 @@ static struct n_hdlc *n_hdlc_alloc(void) {struct n_hdlc_buf *buf;int i; -struct n_hdlc *n_hdlc =kmalloc (sizeof (*n_hdlc),GFP_KERNEL ); +struct n_hdlc *n_hdlc =kzalloc (sizeof (*n_hdlc),GFP_KERNEL );if (!n_hdlc)return NULL ; -memset (n_hdlc,0 ,sizeof (*n_hdlc)); -n_hdlc_buf_list_init (&n_hdlc->rx_free_buf_list);n_hdlc_buf_list_init (&n_hdlc->tx_free_buf_list);n_hdlc_buf_list_init (&n_hdlc->rx_buf_list);
drivers/char/keyboard.c renamed from drivers/char/keyboard.c.orig +1 -2
@@ -1193,9 +1193,8 @@ static struct input_handle *kbd_connect(if (i ==BTN_MISC && !test_bit (EV_SND , dev->evbit))return NULL ; -if (!(handle =kmalloc (sizeof (struct input_handle ),GFP_KERNEL ))) +if (!(handle =kzalloc (sizeof (struct input_handle ),GFP_KERNEL )))return NULL ; -memset (handle,0 ,sizeof (struct input_handle )); handle->dev = dev; handle->handler = handler;
drivers/char/ip2main.c renamed from drivers/char/ip2main.c.orig +1 -2
@@ -648,10 +648,9 @@ ip2_loadmain(int *iop, int *irqp, unsign }/* for */ for ( i =0 ; i <IP2_MAX_BOARDS ; ++i ) {if ( ip2config.addr[i] ) { - pB =kmalloc (sizeof (i2eBordStr),GFP_KERNEL ); + pB =kzalloc (sizeof (i2eBordStr),GFP_KERNEL );if ( pB !=NULL ) { i2BoardPtrTable[i] = pB; -memset ( pB,0 ,sizeof (i2eBordStr) );iiSetAddress ( pB, ip2config.addr[i], ii2DelayTimer );iiReset ( pB ); }else {
drivers/char/vt.c renamed from drivers/char/vt.c.orig +1 -2
@@ -709,10 +709,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;visual_init (vc, currcons,1 );if (!*vc->vc_uni_pagedir_loc)
drivers/char/sx.c renamed from drivers/char/sx.c.orig +1 -13
@@ -2274,18 +2274,6 @@ static int sx_init_drivers(void)return 0 ; } - -static void *ckmalloc (int size) -{ -void *p; - - p =kmalloc (size,GFP_KERNEL ); -if (p) -memset (p,0 , size); -return p; -} - -static int sx_init_portstructs (int nboards,int nports) {struct sx_board *board;
@@ -2298,7 +2286,7 @@ static int sx_init_portstructs (int nboa/* Many drivers statically allocate the maximum number of ports There is no reason not to allocate them dynamically. Is there? -- REW */ - sx_ports =ckmalloc (nports *sizeof (struct sx_port )); + sx_ports =kcalloc (nports,sizeof (struct sx_port ),GFP_KERNEL );if (!sx_ports)return -ENOMEM ;
drivers/char/synclink.c renamed from drivers/char/synclink.c.orig +1 -3
@@ -4352,13 +4352,11 @@ static struct mgsl_struct* mgsl_allocate {struct mgsl_struct *info; - info = (struct mgsl_struct *)kmalloc (sizeof (struct mgsl_struct ), -GFP_KERNEL ); + 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); info->max_frame_size =4096 ;
drivers/char/drm/ffb_drv.c renamed from drivers/char/drm/ffb_drv.c.orig +1 -2
@@ -219,10 +219,9 @@ static int ffb_presetup(drm_device_t * dreturn -ENODEV ;/* code used to use numdevs no numdevs anymore */ - ffb_priv =kmalloc (sizeof (ffb_dev_priv_t),GFP_KERNEL ); + ffb_priv =kzalloc (sizeof (ffb_dev_priv_t),GFP_KERNEL );if (!ffb_priv)return -ENOMEM ; -memset (ffb_priv,0 ,sizeof (*ffb_priv)); dev->dev_private = ffb_priv; ret =ffb_init_one (dev, ffb_position[i].node, ffb_position[i].root, i);
drivers/char/drm/via_dmablit.c renamed from drivers/char/drm/via_dmablit.c.orig +2 -2
@@ -268,10 +268,10 @@ 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 (vsg->num_desc_pages, +sizeof (void *),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] =
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/mtd
In reply to Eric Sesterhennhi,
this patch converts drivers/mtd to kzalloc usage.
Compile tested with allyes config.
drivers/mtd/onenand/generic.c renamed from drivers/mtd/onenand/generic.c.orig +1 -3
@@ -45,12 +45,10 @@ static int __devinit generic_onenand_prounsigned long size = res->end - res->start +1 ;int err; - info =kmalloc (sizeof (struct onenand_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct onenand_info ),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (struct onenand_info )); -if (!request_mem_region (res->start, size, dev->driver->name)) { err = -EBUSY ; goto out_free_info;
drivers/mtd/mtdblock_ro.c renamed from drivers/mtd/mtdblock_ro.c.orig +1 -3
@@ -33,13 +33,11 @@ static int mtdblock_writesect(struct mtdstatic void mtdblock_add_mtd (struct mtd_blktrans_ops *tr,struct mtd_info *mtd) { -struct mtd_blktrans_dev *dev =kmalloc (sizeof (*dev),GFP_KERNEL ); +struct mtd_blktrans_dev *dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return ; -memset (dev,0 ,sizeof (*dev)); - dev->mtd = mtd; dev->devnum = mtd->index; dev->blksize =512 ;
drivers/mtd/mtdblock.c renamed from drivers/mtd/mtdblock.c.orig +2 -5
@@ -278,11 +278,10 @@ static int mtdblock_open(struct mtd_blkt }/* OK, it's not open. Create cache info for it */ - mtdblk =kmalloc (sizeof (struct mtdblk_dev ),GFP_KERNEL ); + mtdblk =kzalloc (sizeof (struct mtdblk_dev ),GFP_KERNEL );if (!mtdblk)return -ENOMEM ; -memset (mtdblk,0 ,sizeof (*mtdblk)); mtdblk->count =1 ; mtdblk->mtd = mtd;
@@ -340,13 +339,11 @@ static int mtdblock_flush(struct mtd_blkstatic void mtdblock_add_mtd (struct mtd_blktrans_ops *tr,struct mtd_info *mtd) { -struct mtd_blktrans_dev *dev =kmalloc (sizeof (*dev),GFP_KERNEL ); +struct mtd_blktrans_dev *dev =kzalloc (sizeof (*dev),GFP_KERNEL );if (!dev)return ; -memset (dev,0 ,sizeof (*dev)); - dev->mtd = mtd; dev->devnum = mtd->index; dev->blksize =512 ;
drivers/mtd/chips/cfi_cmdset_0002.c renamed from drivers/mtd/chips/cfi_cmdset_0002.c.orig +1 -2
@@ -218,12 +218,11 @@ struct mtd_info *cfi_cmdset_0002(structstruct mtd_info *mtd;int i; - mtd =kmalloc (sizeof (*mtd),GFP_KERNEL ); + mtd =kzalloc (sizeof (*mtd),GFP_KERNEL );if (!mtd) {printk (KERN_WARNING "Failed to allocate memory for MTD device\n" );return NULL ; } -memset (mtd,0 ,sizeof (*mtd)); mtd->priv = map; mtd->type =MTD_NORFLASH ;
drivers/mtd/chips/amd_flash.c renamed from drivers/mtd/chips/amd_flash.c.orig +1 -2
@@ -650,13 +650,12 @@ static struct mtd_info *amd_flash_probe(int reg_idx;int offset; - mtd = (struct mtd_info *)kmalloc (sizeof (*mtd),GFP_KERNEL ); + mtd =kzalloc (sizeof (*mtd),GFP_KERNEL );if (!mtd) {printk (KERN_WARNING "%s: kmalloc failed for info structure\n" , map->name);return NULL ; } -memset (mtd,0 ,sizeof (*mtd)); mtd->priv = map;memset (&temp,0 ,sizeof (temp));
drivers/mtd/chips/jedec.c renamed from drivers/mtd/chips/jedec.c.orig +1 -2
@@ -116,11 +116,10 @@ static struct mtd_info *jedec_probe(struchar Part[200 ];memset (&priv,0 ,sizeof (priv)); -MTD =kmalloc (sizeof (struct mtd_info ) +sizeof (struct jedec_private ),GFP_KERNEL ); +MTD =kzalloc (sizeof (struct mtd_info ) +sizeof (struct jedec_private ),GFP_KERNEL );if (!MTD )return NULL ; -memset (MTD ,0 ,sizeof (struct mtd_info ) +sizeof (struct jedec_private )); priv = (struct jedec_private *)&MTD [1 ]; my_bank_size = map->size;
drivers/mtd/chips/cfi_cmdset_0001.c renamed from drivers/mtd/chips/cfi_cmdset_0001.c.orig +1 -2
@@ -344,12 +344,11 @@ struct mtd_info *cfi_cmdset_0001(structstruct mtd_info *mtd;int i; - mtd =kmalloc (sizeof (*mtd),GFP_KERNEL ); + mtd =kzalloc (sizeof (*mtd),GFP_KERNEL );if (!mtd) {printk (KERN_ERR "Failed to allocate memory for MTD device\n" );return NULL ; } -memset (mtd,0 ,sizeof (*mtd)); mtd->priv = map; mtd->type =MTD_NORFLASH ;
drivers/mtd/chips/gen_probe.c renamed from drivers/mtd/chips/gen_probe.c.orig +1 -2
@@ -101,13 +101,12 @@ static struct cfi_private *genprobe_iden*/ max_chips = map->size >> cfi.chipshift; mapsize = (max_chips /8 ) + ((max_chips %8 ) ?1 :0 ); - chip_map =kmalloc (mapsize,GFP_KERNEL ); + chip_map =kzalloc (mapsize,GFP_KERNEL );if (!chip_map) {printk (KERN_WARNING "%s: kmalloc failed for CFI chip map\n" , map->name);kfree (cfi.cfiq);return NULL ; } -memset (chip_map,0 , mapsize);set_bit (0 , chip_map);/* Mark first chip valid */
drivers/mtd/chips/map_ram.c renamed from drivers/mtd/chips/map_ram.c.orig +1 -3
@@ -55,12 +55,10 @@ static struct mtd_info *map_ram_probe(st#endif /* OK. It seems to be RAM. */ - mtd =kmalloc (sizeof (*mtd),GFP_KERNEL ); + mtd =kzalloc (sizeof (*mtd),GFP_KERNEL );if (!mtd)return NULL ; -memset (mtd,0 ,sizeof (*mtd)); - map->fldrv = &mapram_chipdrv; mtd->priv = map; mtd->name = map->name;
drivers/mtd/chips/map_rom.c renamed from drivers/mtd/chips/map_rom.c.orig +1 -3
@@ -31,12 +31,10 @@ static struct mtd_info *map_rom_probe(st {struct mtd_info *mtd; - mtd =kmalloc (sizeof (*mtd),GFP_KERNEL ); + mtd =kzalloc (sizeof (*mtd),GFP_KERNEL );if (!mtd)return NULL ; -memset (mtd,0 ,sizeof (*mtd)); - map->fldrv = &maprom_chipdrv; mtd->priv = map; mtd->name = map->name;
drivers/mtd/mtd_blkdevs.c renamed from drivers/mtd/mtd_blkdevs.c.orig +1 -3
@@ -372,12 +372,10 @@ int register_mtd_blktrans(struct mtd_blkif (!blktrans_notifier.list.next)register_mtd_user (&blktrans_notifier); - tr->blkcore_priv =kmalloc (sizeof (*tr->blkcore_priv),GFP_KERNEL ); + tr->blkcore_priv =kzalloc (sizeof (*tr->blkcore_priv),GFP_KERNEL );if (!tr->blkcore_priv)return -ENOMEM ; -memset (tr->blkcore_priv,0 ,sizeof (*tr->blkcore_priv)); -mutex_lock (&mtd_table_mutex); ret =register_blkdev (tr->major, tr->name);
drivers/mtd/afs.c renamed from drivers/mtd/afs.c.orig +1 -2
@@ -207,11 +207,10 @@ static int parse_afs_partitions(struct mif (!sz)return ret; - parts =kmalloc (sz,GFP_KERNEL ); + parts =kzalloc (sz,GFP_KERNEL );if (!parts)return -ENOMEM ; -memset (parts,0 , sz); str = (char *)(parts + idx);/*
drivers/mtd/devices/pmc551.c renamed from drivers/mtd/devices/pmc551.c.orig +2 -5
@@ -712,21 +712,18 @@ static int __init init_pmc551(void) msize = length; } - mtd =kmalloc (sizeof (struct mtd_info ),GFP_KERNEL ); + mtd =kzalloc (sizeof (struct mtd_info ),GFP_KERNEL );if (!mtd) {printk (KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n" );break ; } -memset (mtd,0 ,sizeof (struct mtd_info )); - - priv =kmalloc (sizeof (struct mypriv ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct mypriv ),GFP_KERNEL );if (!priv) {printk (KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n" );kfree (mtd);break ; } -memset (priv,0 ,sizeof (*priv)); mtd->priv = priv; priv->dev = PCI_Device;
drivers/mtd/devices/phram.c renamed from drivers/mtd/devices/phram.c.orig +1 -3
@@ -126,12 +126,10 @@ static int register_device(char *name, ustruct phram_mtd_list *new;int ret = -ENOMEM ; - new =kmalloc (sizeof (*new),GFP_KERNEL ); + new =kzalloc (sizeof (*new),GFP_KERNEL );if (!new) goto out0; -memset (new,0 ,sizeof (*new)); - ret = -EIO ; new->mtd.priv =ioremap (start, len);if (!new->mtd.priv) {
drivers/mtd/devices/ms02-nv.c renamed from drivers/mtd/devices/ms02-nv.c.orig +6 -12
@@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulongint ret = -ENODEV ;/* The module decodes 8MiB of address space. */ - mod_res =kmalloc (sizeof (*mod_res),GFP_KERNEL ); + mod_res =kzalloc (sizeof (*mod_res),GFP_KERNEL );if (!mod_res)return -ENOMEM ; -memset (mod_res,0 ,sizeof (*mod_res)); mod_res->name = ms02nv_name; mod_res->start = addr; mod_res->end = addr +MS02NV_SLOT_SIZE -1 ;
@@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong } ret = -ENOMEM ; - mtd =kmalloc (sizeof (*mtd),GFP_KERNEL ); + mtd =kzalloc (sizeof (*mtd),GFP_KERNEL );if (!mtd) goto err_out_mod_res_rel; -memset (mtd,0 ,sizeof (*mtd)); - mp =kmalloc (sizeof (*mp),GFP_KERNEL ); + mp =kzalloc (sizeof (*mp),GFP_KERNEL );if (!mp) goto err_out_mtd; -memset (mp,0 ,sizeof (*mp)); mtd->priv = mp; mp->resource.module = mod_res;/* Firmware's diagnostic NVRAM area. */ - diag_res =kmalloc (sizeof (*diag_res),GFP_KERNEL ); + diag_res =kzalloc (sizeof (*diag_res),GFP_KERNEL );if (!diag_res) goto err_out_mp; -memset (diag_res,0 ,sizeof (*diag_res)); diag_res->name = ms02nv_res_diag_ram; diag_res->start = addr; diag_res->end = addr +MS02NV_RAM -1 ;
@@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong mp->resource.diag_ram = diag_res;/* User-available general-purpose NVRAM area. */ - user_res =kmalloc (sizeof (*user_res),GFP_KERNEL ); + user_res =kzalloc (sizeof (*user_res),GFP_KERNEL );if (!user_res) goto err_out_diag_res; -memset (user_res,0 ,sizeof (*user_res)); user_res->name = ms02nv_res_user_ram; user_res->start = addr +MS02NV_RAM ; user_res->end = addr + size -1 ;
@@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong mp->resource.user_ram = user_res;/* Control and status register. */ - csr_res =kmalloc (sizeof (*csr_res),GFP_KERNEL ); + csr_res =kzalloc (sizeof (*csr_res),GFP_KERNEL );if (!csr_res) goto err_out_user_res; -memset (csr_res,0 ,sizeof (*csr_res)); csr_res->name = ms02nv_res_csr; csr_res->start = addr +MS02NV_CSR ; csr_res->end = addr +MS02NV_CSR +3 ;
drivers/mtd/devices/block2mtd.c renamed from drivers/mtd/devices/block2mtd.c.orig +1 -2
@@ -293,10 +293,9 @@ static struct block2mtd_dev *add_device(if (!devname)return NULL ; - dev =kmalloc (sizeof (struct block2mtd_dev ),GFP_KERNEL ); + dev =kzalloc (sizeof (struct block2mtd_dev ),GFP_KERNEL );if (!dev)return NULL ; -memset (dev,0 ,sizeof (*dev));/* Get a handle on the device */ bdev =open_bdev_excl (devname,O_RDWR ,NULL );
drivers/mtd/devices/slram.c renamed from drivers/mtd/devices/slram.c.orig +2 -5
@@ -168,19 +168,16 @@ static int register_device(char *name, uE ("slram: Cannot allocate new MTD device.\n" );return (-ENOMEM ); } - (*curmtd)->mtdinfo =kmalloc (sizeof (struct mtd_info ),GFP_KERNEL ); + (*curmtd)->mtdinfo =kzalloc (sizeof (struct mtd_info ),GFP_KERNEL ); (*curmtd)->next =NULL ;if ((*curmtd)->mtdinfo) { -memset ((char *)(*curmtd)->mtdinfo,0 ,sizeof (struct mtd_info )); (*curmtd)->mtdinfo->priv = -kmalloc (sizeof (slram_priv_t),GFP_KERNEL ); +kzalloc (sizeof (slram_priv_t),GFP_KERNEL );if (!(*curmtd)->mtdinfo->priv) {kfree ((*curmtd)->mtdinfo); (*curmtd)->mtdinfo =NULL ; - }else { -memset ((*curmtd)->mtdinfo->priv,0 ,sizeof (slram_priv_t)); } }
drivers/mtd/maps/ceiva.c renamed from drivers/mtd/maps/ceiva.c.orig +1 -2
@@ -123,10 +123,9 @@ static int __init clps_setup_mtd(struct/* * Allocate the map_info structs in one go. */ - maps =kmalloc (sizeof (struct map_info ) * nr,GFP_KERNEL ); + maps =kcalloc (nr,sizeof (struct map_info ),GFP_KERNEL );if (!maps)return -ENOMEM ; -memset (maps,0 ,sizeof (struct map_info ) * nr);/* * Claim and then map the memory regions. */
drivers/mtd/maps/tqm834x.c renamed from drivers/mtd/maps/tqm834x.c.orig +2 -6
@@ -133,20 +133,16 @@ static int __init init_tqm834x_mtd(void)pr_debug ("%s: chip probing count %d\n" , __FUNCTION__, idx); - map_banks[idx] = - (struct map_info *)kmalloc (sizeof (struct map_info ), -GFP_KERNEL ); + map_banks[idx] =kzalloc (sizeof (struct map_info ),GFP_KERNEL );if (map_banks[idx] ==NULL ) { ret = -ENOMEM ; goto error_mem; } -memset ((void *)map_banks[idx],0 ,sizeof (struct map_info )); - map_banks[idx]->name = (char *)kmalloc (16 ,GFP_KERNEL ); + map_banks[idx]->name =kzalloc (16 ,GFP_KERNEL );if (map_banks[idx]->name ==NULL ) { ret = -ENOMEM ; goto error_mem; } -memset ((void *)map_banks[idx]->name,0 ,16 );sprintf (map_banks[idx]->name,"TQM834x-%d" , idx); map_banks[idx]->size = flash_size;
drivers/mtd/maps/tqm8xxl.c renamed from drivers/mtd/maps/tqm8xxl.c.orig +1 -2
@@ -135,14 +135,13 @@ int __init init_tqm_mtd(void)printk (KERN_INFO "%s: chip probing count %d\n" , __FUNCTION__, idx); - map_banks[idx] = (struct map_info *)kmalloc (sizeof (struct map_info ),GFP_KERNEL ); + map_banks[idx] =kzalloc (sizeof (struct map_info ),GFP_KERNEL );if (map_banks[idx] ==NULL ) { ret = -ENOMEM ;/* FIXME: What if some MTD devices were probed already? */ goto error_mem; } -memset ((void *)map_banks[idx],0 ,sizeof (struct map_info )); map_banks[idx]->name = (char *)kmalloc (16 ,GFP_KERNEL );if (!map_banks[idx]->name) {
drivers/mtd/maps/omap_nor.c renamed from drivers/mtd/maps/omap_nor.c.orig +1 -3
@@ -78,12 +78,10 @@ static int __devinit omapflash_probe(strstruct resource *res = pdev->resource;unsigned long size = res->end - res->start +1 ; - info =kmalloc (sizeof (struct omapflash_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct omapflash_info ),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (struct omapflash_info )); -if (!request_mem_region (res->start, size,"flash" )) { err = -EBUSY ; goto out_free_info;
drivers/mtd/nand/diskonchip.c renamed from drivers/mtd/nand/diskonchip.c.orig +1 -2
@@ -1645,13 +1645,12 @@ static int __init doc_probe(unsigned lonsizeof (struct nand_chip ) +sizeof (struct doc_priv ) + (2 *sizeof (struct nand_bbt_descr )); - mtd =kmalloc (len,GFP_KERNEL ); + mtd =kzalloc (len,GFP_KERNEL );if (!mtd) {printk (KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n" , len); ret = -ENOMEM ; goto fail; } -memset (mtd,0 , len); nand = (struct nand_chip *) (mtd +1 ); doc = (struct doc_priv *) (nand +1 );
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/serial
In reply to Eric Sesterhennhi,
this patch converts drivers/serial to kzalloc usage. Compile tested with allyes config.
ip22zilog.c and sunzilog.c contained their own kzalloc() variant alloc_one_table() which i removed, and replaced the callers with kzalloc()
drivers/serial/ioc4_serial.c renamed from drivers/serial/ioc4_serial.c.orig +2 -4
@@ -1034,13 +1034,12 @@ static int inline ioc4_attach_local(stru/* Create port structures for each port */ for (port_number =0 ; port_number <IOC4_NUM_SERIAL_PORTS ; port_number++) { - port =kmalloc (sizeof (struct ioc4_port ),GFP_KERNEL ); + port =kzalloc (sizeof (struct ioc4_port ),GFP_KERNEL );if (!port) {printk (KERN_WARNING "IOC4 serial memory not available for port\n" );return -ENOMEM ; } -memset (port,0 ,sizeof (struct ioc4_port ));spin_lock_init (&port->ip_lock);/* we need to remember the previous ones, to point back to
@@ -2671,7 +2670,7 @@ ioc4_serial_attach_one(struct ioc4_drive idd->idd_serial_data = control;/* Allocate the soft structure */ - soft =kmalloc (sizeof (struct ioc4_soft ),GFP_KERNEL ); + soft =kzalloc (sizeof (struct ioc4_soft ),GFP_KERNEL );if (!soft) { printk(KERN_WARNING "ioc4 (%p): unable to get memory for the soft struct\n",
@@ -2679,7 +2678,6 @@ ioc4_serial_attach_one(struct ioc4_drive ret = -ENOMEM ; goto out3; } -memset (soft,0 ,sizeof (struct ioc4_soft ));spin_lock_init (&soft->is_ir_lock); soft->is_ioc4_misc_addr = idd->idd_misc_regs;
drivers/serial/serial_cs.c renamed from drivers/serial/serial_cs.c.orig +1 -2
@@ -212,10 +212,9 @@ static int serial_probe(struct pcmcia_deDEBUG (0 ,"serial_attach()\n" );/* Create new serial 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/serial/8250_acorn.c renamed from drivers/serial/8250_acorn.c.orig +1 -2
@@ -47,11 +47,10 @@ serial_card_probe(struct expansion_cardunsigned char __iomem *virt_addr;unsigned int i; - info =kmalloc (sizeof (struct serial_card_info ),GFP_KERNEL ); + info =kzalloc (sizeof (struct serial_card_info ),GFP_KERNEL );if (!info)return -ENOMEM ; -memset (info,0 ,sizeof (struct serial_card_info )); info->num_ports = type->num_ports; bus_addr =ecard_resource_start (ec, type->type);
drivers/serial/8250_acpi.c renamed from drivers/serial/8250_acpi.c.orig +1 -2
@@ -104,12 +104,11 @@ static int acpi_serial_add(struct acpi_d port.uartclk =1843200 ; port.flags =UPF_SKIP_TEST |UPF_BOOT_AUTOCONF ; - priv =kmalloc (sizeof (struct serial_private ),GFP_KERNEL ); + priv =kzalloc (sizeof (struct serial_private ),GFP_KERNEL );if (!priv) { result = -ENOMEM ; goto fail; } -memset (priv,0 ,sizeof (*priv)); status =acpi_walk_resources (device->handle,METHOD_NAME__CRS , acpi_serial_resource, &port);
drivers/serial/sunsu.c renamed from drivers/serial/sunsu.c.orig +1 -3
@@ -1303,10 +1303,8 @@ static int __init sunsu_kbd_ms_init(stru sunsu_type(&up->port));#ifdef CONFIG_SERIO - up->serio = serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); + up->serio = serio =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (serio) { -memset (serio,0 ,sizeof (*serio)); - serio->port_data = up; serio->id.type =SERIO_RS232 ;
drivers/serial/sunzilog.c renamed from drivers/serial/sunzilog.c.orig +3 -16
@@ -1022,23 +1022,12 @@ static struct uart_driver sunzilog_reg = .major = TTY_MAJOR, }; -static void *__init alloc_one_table (unsigned long size) -{ -void *ret; - - ret =kmalloc (size,GFP_KERNEL ); -if (ret !=NULL ) -memset (ret,0 , size); - -return ret; -} -static void __init sunzilog_alloc_tables (void ) { sunzilog_port_table = -alloc_one_table (NUM_CHANNELS *sizeof (struct uart_sunzilog_port )); +kzalloc (NUM_CHANNELS *sizeof (struct uart_sunzilog_port ),GFP_KERNEL ); sunzilog_chip_regs = -alloc_one_table (NUM_SUNZILOG *sizeof (struct zilog_layout __iomem *)); +kzalloc (NUM_SUNZILOG *sizeof (struct zilog_layout __iomem *),GFP_KERNEL );if (sunzilog_port_table ==NULL || sunzilog_chip_regs ==NULL ) {prom_printf ("SunZilog: Cannot allocate tables.\n" );
@@ -1555,10 +1544,8 @@ static void __init sunzilog_register_ser {struct serio *serio; - up->serio = serio =kmalloc (sizeof (struct serio ),GFP_KERNEL ); + up->serio = serio =kzalloc (sizeof (struct serio ),GFP_KERNEL );if (serio) { -memset (serio,0 ,sizeof (*serio)); - serio->port_data = up; serio->id.type =SERIO_RS232 ;
drivers/serial/ip22zilog.c renamed from drivers/serial/ip22zilog.c.orig +4 -15
@@ -925,23 +925,12 @@ static struct zilog_layout **ip22zilog_cstatic struct uart_ip22zilog_port *ip22zilog_irq_chain;static int zilog_irq =-1 ; -static void *__init alloc_one_table (unsigned long size) -{ -void *ret; - - ret =kmalloc (size,GFP_KERNEL ); -if (ret !=NULL ) -memset (ret,0 , size); - -return ret; -} -static void __init ip22zilog_alloc_tables (void ) { - ip22zilog_port_table = (struct uart_ip22zilog_port *) -alloc_one_table (NUM_CHANNELS *sizeof (struct uart_ip22zilog_port )); - ip22zilog_chip_regs = (struct zilog_layout **) -alloc_one_table (NUM_IP22ZILOG *sizeof (struct zilog_layout *)); + ip22zilog_port_table = +kzalloc (NUM_CHANNELS *sizeof (struct uart_ip22zilog_port ),GFP_KERNEL ); + ip22zilog_chip_regs = +kzalloc (NUM_IP22ZILOG *sizeof (struct zilog_layout *),GFP_KERNEL );if (ip22zilog_port_table ==NULL || ip22zilog_chip_regs ==NULL ) {panic ("IP22-Zilog: Cannot allocate IP22-Zilog tables." );
drivers/serial/serial_core.c renamed from drivers/serial/serial_core.c.orig +2 -5
@@ -1492,9 +1492,8 @@ static struct uart_state *uart_get(struc }if (!state->info) { - state->info =kmalloc (sizeof (struct uart_info ),GFP_KERNEL ); + state->info =kzalloc (sizeof (struct uart_info ),GFP_KERNEL );if (state->info) { -memset (state->info,0 ,sizeof (struct uart_info ));init_waitqueue_head (&state->info->open_wait);init_waitqueue_head (&state->info->delta_msr_wait);
@@ -2152,13 +2151,11 @@ int uart_register_driver(struct uart_dri* Maybe we should be using a slab cache for this, especially if * we have a large number of ports to handle. */ - drv->state =kmalloc (sizeof (struct uart_state ) * drv->nr,GFP_KERNEL ); + drv->state =kcalloc (drv->nr,sizeof (struct uart_state ),GFP_KERNEL ); retval = -ENOMEM ;if (!drv->state) goto out; -memset (drv->state,0 ,sizeof (struct uart_state ) * drv->nr); - normal =alloc_tty_driver (drv->nr);if (!normal) goto out;
drivers/serial/jsm/jsm_tty.c renamed from drivers/serial/jsm/jsm_tty.c.orig +4 -8
@@ -194,31 +194,28 @@ static int jsm_tty_open(struct uart_port/* Drop locks, as malloc with GFP_KERNEL can sleep */ if (!channel->ch_rqueue) { - channel->ch_rqueue = (u8 *)kmalloc (RQUEUESIZE ,GFP_KERNEL ); + channel->ch_rqueue =kzalloc (RQUEUESIZE ,GFP_KERNEL );if (!channel->ch_rqueue) {jsm_printk (INIT ,ERR , &channel->ch_bd->pci_dev,"unable to allocate read queue buf" );return -ENOMEM ; } -memset (channel->ch_rqueue,0 ,RQUEUESIZE ); }if (!channel->ch_equeue) { - channel->ch_equeue = (u8 *)kmalloc (EQUEUESIZE ,GFP_KERNEL ); + channel->ch_equeue =kzalloc (EQUEUESIZE ,GFP_KERNEL );if (!channel->ch_equeue) {jsm_printk (INIT ,ERR , &channel->ch_bd->pci_dev,"unable to allocate error queue buf" );return -ENOMEM ; } -memset (channel->ch_equeue,0 ,EQUEUESIZE ); }if (!channel->ch_wqueue) { - channel->ch_wqueue = (u8 *)kmalloc (WQUEUESIZE ,GFP_KERNEL ); + channel->ch_wqueue =kzalloc (WQUEUESIZE ,GFP_KERNEL );if (!channel->ch_wqueue) {jsm_printk (INIT ,ERR , &channel->ch_bd->pci_dev,"unable to allocate write queue buf" );return -ENOMEM ; } -memset (channel->ch_wqueue,0 ,WQUEUESIZE ); } channel->ch_flags &= ~(CH_OPENING );
@@ -392,13 +389,12 @@ int jsm_tty_init(struct jsm_board *brd)* Okay to malloc with GFP_KERNEL, we are not at * interrupt context, and there are no locks held. */ - brd->channels[i] =kmalloc (sizeof (struct jsm_channel ),GFP_KERNEL ); + brd->channels[i] =kzalloc (sizeof (struct jsm_channel ),GFP_KERNEL );if (!brd->channels[i]) {jsm_printk (CORE ,ERR , &brd->pci_dev,"%s:%d Unable to allocate memory for channel struct\n" , __FILE__, __LINE__); } -memset (brd->channels[i],0 ,sizeof (struct jsm_channel )); } }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/md
In reply to Eric Sesterhennhi,
this patch converts drivers/md to kzalloc usage.
Compile tested with allyes config.
drivers/md/dm-path-selector.c renamed from drivers/md/dm-path-selector.c.orig +2 -4
@@ -95,12 +95,10 @@ out:static struct ps_internal *_alloc_path_selector (struct path_selector_type *pst) { -struct ps_internal *psi =kmalloc (sizeof (*psi),GFP_KERNEL ); +struct ps_internal *psi =kzalloc (sizeof (*psi),GFP_KERNEL ); -if (psi) { -memset (psi,0 ,sizeof (*psi)); +if (psi) psi->pst = *pst; - }return psi; }
drivers/md/dm-hw-handler.c renamed from drivers/md/dm-hw-handler.c.orig +2 -4
@@ -92,12 +92,10 @@ void dm_put_hw_handler(struct hw_handlerstatic struct hwh_internal *_alloc_hw_handler (struct hw_handler_type *hwht) { -struct hwh_internal *hwhi =kmalloc (sizeof (*hwhi),GFP_KERNEL ); +struct hwh_internal *hwhi =kzalloc (sizeof (*hwhi),GFP_KERNEL ); -if (hwhi) { -memset (hwhi,0 ,sizeof (*hwhi)); +if (hwhi) hwhi->hwht = *hwht; - }return hwhi; }
drivers/md/dm-emc.c renamed from drivers/md/dm-emc.c.orig +2 -4
@@ -221,12 +221,10 @@ fail_path:static struct emc_handler *alloc_emc_handler (void ) { -struct emc_handler *h =kmalloc (sizeof (*h),GFP_KERNEL ); +struct emc_handler *h =kzalloc (sizeof (*h),GFP_KERNEL ); -if (h) { -memset (h,0 ,sizeof (*h)); +if (h)spin_lock_init (&h->lock); - }return h; }
drivers/md/dm-target.c renamed from drivers/md/dm-target.c.orig +2 -4
@@ -87,12 +87,10 @@ void dm_put_target_type(struct target_tystatic struct tt_internal *alloc_target (struct target_type *t) { -struct tt_internal *ti =kmalloc (sizeof (*ti),GFP_KERNEL ); +struct tt_internal *ti =kzalloc (sizeof (*ti),GFP_KERNEL ); -if (ti) { -memset (ti,0 ,sizeof (*ti)); +if (ti) ti->tt = *t; - }return ti; }
drivers/md/dm-mpath.c renamed from drivers/md/dm-mpath.c.orig +4 -8
@@ -113,12 +113,10 @@ static void trigger_event(void *data);static struct pgpath *alloc_pgpath (void ) { -struct pgpath *pgpath =kmalloc (sizeof (*pgpath),GFP_KERNEL ); +struct pgpath *pgpath =kzalloc (sizeof (*pgpath),GFP_KERNEL ); -if (pgpath) { -memset (pgpath,0 ,sizeof (*pgpath)); +if (pgpath) pgpath->path.is_active =1 ; - }return pgpath; }
@@ -132,11 +130,10 @@ static struct priority_group *alloc_prio {struct priority_group *pg; - pg =kmalloc (sizeof (*pg),GFP_KERNEL ); + pg =kzalloc (sizeof (*pg),GFP_KERNEL );if (!pg)return NULL ; -memset (pg,0 ,sizeof (*pg));INIT_LIST_HEAD (&pg->pgpaths);return pg;
@@ -171,9 +168,8 @@ static struct multipath *alloc_multipath {struct multipath *m; - m =kmalloc (sizeof (*m),GFP_KERNEL ); + m =kzalloc (sizeof (*m),GFP_KERNEL );if (m) { -memset (m,0 ,sizeof (*m));INIT_LIST_HEAD (&m->priority_groups);spin_lock_init (&m->lock); m->queue_io =1 ;
drivers/md/dm-table.c renamed from drivers/md/dm-table.c.orig +1 -2
@@ -209,12 +209,11 @@ static int alloc_targets(struct dm_tableint dm_table_create (struct dm_table **result,int mode,unsigned num_targets) { -struct dm_table *t =kmalloc (sizeof (*t),GFP_KERNEL ); +struct dm_table *t =kzalloc (sizeof (*t),GFP_KERNEL );if (!t)return -ENOMEM ; -memset (t,0 ,sizeof (*t));INIT_LIST_HEAD (&t->devices);atomic_set (&t->holders,1 );
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/macintosh
In reply to Eric Sesterhennhi,
this patch converts drivers/macintosh to kzalloc usage. Not tested.
drivers/macintosh/therm_pm72.c renamed from drivers/macintosh/therm_pm72.c.orig +1 -2
@@ -306,10 +306,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/windfarm_lm75_sensor.c renamed from drivers/macintosh/windfarm_lm75_sensor.c.orig +1 -2
@@ -116,10 +116,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/macintosh/smu.c renamed from drivers/macintosh/smu.c.orig +1 -2
@@ -1035,10 +1035,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_windtunnel.c renamed from drivers/macintosh/therm_windtunnel.c.orig +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/therm_adt746x.c renamed from drivers/macintosh/therm_adt746x.c.orig +1 -3
@@ -379,13 +379,11 @@ static int attach_one_thermostat(structif (thermostat)return 0 ; - th = (struct thermostat *) -kmalloc (sizeof (struct thermostat ),GFP_KERNEL ); + th =kzalloc (sizeof (struct thermostat ),GFP_KERNEL );if (!th)return -ENOMEM ; -memset (th,0 ,sizeof (*th)); th->clt.addr = addr; th->clt.adapter = adapter; th->clt.driver = &thermostat_driver;
drivers/macintosh/macio_asic.c renamed from drivers/macintosh/macio_asic.c.orig +1 -2
@@ -407,10 +407,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;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/block
In reply to Eric Sesterhennhi,
this patch converts drivers/block to kzalloc usage. Compile tested with allyesconfig.
block/ll_rw_blk.c renamed from block/ll_rw_blk.c.orig +2 -4
@@ -903,17 +903,15 @@ init_tag_map(request_queue_t *q, struct __FUNCTION__, depth); } - tag_index =kmalloc (depth *sizeof (struct request *),GFP_ATOMIC ); + tag_index =kcalloc (depth,sizeof (struct request *),GFP_ATOMIC );if (!tag_index) goto fail; nr_ulongs =ALIGN (depth,BITS_PER_LONG ) /BITS_PER_LONG ; - tag_map =kmalloc (nr_ulongs *sizeof (unsigned long ),GFP_ATOMIC ); + tag_map =kcalloc (nr_ulongs,sizeof (unsigned long ),GFP_ATOMIC );if (!tag_map) goto fail; -memset (tag_index,0 , depth *sizeof (struct request *)); -memset (tag_map,0 , nr_ulongs *sizeof (unsigned long )); tags->real_max_depth = depth; tags->max_depth = depth; tags->tag_index = tag_index;
block/scsi_ioctl.c renamed from block/scsi_ioctl.c.orig +1 -3
@@ -378,11 +378,9 @@ static int sg_scsi_ioctl(struct file *fi 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);
block/cfq-iosched.c renamed from block/cfq-iosched.c.orig +1 -3
@@ -2158,12 +2158,10 @@ static int cfq_init_queue(request_queue_struct cfq_data *cfqd;int i; - cfqd =kmalloc (sizeof (*cfqd),GFP_KERNEL ); + cfqd =kzalloc (sizeof (*cfqd),GFP_KERNEL );if (!cfqd)return -ENOMEM ; -memset (cfqd,0 ,sizeof (*cfqd)); -for (i =0 ; i <CFQ_PRIO_LISTS ; i++)INIT_LIST_HEAD (&cfqd->rr_list[i]);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/sbus
In reply to Eric Sesterhennhi,
this patch converts drivers/sbus to kzalloc usage. Not tested
drivers/sbus/char/bbc_envctrl.c renamed from drivers/sbus/char/bbc_envctrl.c.orig +2 -4
@@ -485,11 +485,10 @@ static int kenvctrld(void *__unused)static void attach_one_temp (struct linux_ebus_child *echild,int temp_idx) { -struct bbc_cpu_temperature *tp =kmalloc (sizeof (*tp),GFP_KERNEL ); +struct bbc_cpu_temperature *tp =kzalloc (sizeof (*tp),GFP_KERNEL );if (!tp)return ; -memset (tp,0 ,sizeof (*tp)); tp->client =bbc_i2c_attach (echild);if (!tp->client) {kfree (tp);
@@ -531,11 +530,10 @@ static void attach_one_temp(struct linuxstatic void attach_one_fan (struct linux_ebus_child *echild,int fan_idx) { -struct bbc_fan_control *fp =kmalloc (sizeof (*fp),GFP_KERNEL ); +struct bbc_fan_control *fp =kzalloc (sizeof (*fp),GFP_KERNEL );if (!fp)return ; -memset (fp,0 ,sizeof (*fp)); fp->client =bbc_i2c_attach (echild);if (!fp->client) {kfree (fp);
drivers/sbus/char/openprom.c renamed from drivers/sbus/char/openprom.c.orig +2 -4
@@ -87,9 +87,8 @@ static int copyin(struct openpromio __usif (bufsize >OPROMMAXPARAM ) bufsize =OPROMMAXPARAM ; -if (!(*opp_p =kmalloc (sizeof (int ) + bufsize +1 ,GFP_KERNEL ))) +if (!(*opp_p =kzalloc (sizeof (int ) + bufsize +1 ,GFP_KERNEL )))return -ENOMEM ; -memset (*opp_p,0 ,sizeof (int ) + bufsize +1 );if (copy_from_user (&(*opp_p)->oprom_array, &info->oprom_array, bufsize)) {
@@ -107,10 +106,9 @@ static int getstrings(struct openpromioif (!info || !opp_p)return -EFAULT ; -if (!(*opp_p =kmalloc (sizeof (int ) +OPROMMAXPARAM +1 ,GFP_KERNEL ))) +if (!(*opp_p =kzalloc (sizeof (int ) +OPROMMAXPARAM +1 ,GFP_KERNEL )))return -ENOMEM ; -memset (*opp_p,0 ,sizeof (int ) +OPROMMAXPARAM +1 ); (*opp_p)->oprom_size =0 ; n = bufsize =0 ;
drivers/sbus/char/bbc_i2c.c renamed from drivers/sbus/char/bbc_i2c.c.orig +2 -4
@@ -155,10 +155,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;
@@ -356,13 +355,12 @@ static void __init reset_one_i2c(structstatic int __init attach_one_i2c (struct linux_ebus_device *edev,int index) { -struct bbc_i2c_bus *bp =kmalloc (sizeof (*bp),GFP_KERNEL ); +struct bbc_i2c_bus *bp =kzalloc (sizeof (*bp),GFP_KERNEL );struct linux_ebus_child *echild;int entry;if (!bp)return -ENOMEM ; -memset (bp,0 ,sizeof (*bp)); bp->i2c_control_regs =ioremap (edev->resource[0 ].start,0x2 );if (!bp->i2c_control_regs)
drivers/sbus/char/vfc_dev.c renamed from drivers/sbus/char/vfc_dev.c.orig +2 -6
@@ -264,11 +264,10 @@ static int vfc_debug(struct vfc_dev *devif (copy_from_user (&inout, argp,sizeof (inout)))return -EFAULT ; - buffer =kmalloc (inout.len,GFP_KERNEL ); + buffer =kzalloc (inout.len,GFP_KERNEL );if (buffer ==NULL )return -ENOMEM ; -memset (buffer,0 ,inout.len);vfc_lock_device (dev); inout.ret= vfc_i2c_recvbuf(dev,inout.addr & 0xff
@@ -663,12 +662,9 @@ static int vfc_probe(void)if (!cards)return -ENODEV ; - vfc_dev_lst = (struct vfc_dev **)kmalloc (sizeof (struct vfc_dev *) * - (cards+1 ), -GFP_KERNEL ); + vfc_dev_lst =kcalloc ((cards+1 ),sizeof (struct vfc_dev *),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);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/telephony/
In reply to Eric Sesterhennhi,
this patch converts drivers/rapidio to kzalloc usage. Compile tested with allyesconfig.
drivers/telephony/ixj_pcmcia.c renamed from drivers/telephony/ixj_pcmcia.c.orig +1 -2
@@ -46,11 +46,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); }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/rapidio
In reply to Eric Sesterhennhi,
this patch converts drivers/rapidio to kzalloc usage. Not tested.
drivers/rapidio/rio-scan.c renamed from drivers/rapidio/rio-scan.c.orig +2 -4
@@ -298,11 +298,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);
@@ -785,9 +784,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);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/misc/
In reply to Eric Sesterhennhi,
this patch converts drivers/misc/ to kzalloc usage. Compile tested with allyesconfig.
drivers/misc/ibmasm/command.c renamed from drivers/misc/ibmasm/command.c.orig +2 -5
@@ -41,18 +41,15 @@ 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 renamed from drivers/misc/ibmasm/ibmasmfs.c.orig +1 -3
@@ -563,12 +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);return -EFAULT ;
drivers/misc/ibmasm/module.c renamed from drivers/misc/ibmasm/module.c.orig +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 )); sp->lock =SPIN_LOCK_UNLOCKED ;INIT_LIST_HEAD (&sp->command_queue);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/mfd/
In reply to Eric Sesterhennhi,
this patch converts drivers/mfd/ to kzalloc usage. Compile tested with allyesconfig.
drivers/mfd/ucb1x00-core.c renamed from drivers/mfd/ucb1x00-core.c.orig +1 -3
@@ -483,13 +483,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;strlcpy (ucb->cdev.class_id,"ucb1x00" ,sizeof (ucb->cdev.class_id));
drivers/mfd/mcp-core.c renamed from drivers/mfd/mcp-core.c.orig +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;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/media/
In reply to Eric Sesterhennhi,
this patch converts drivers/media/ to kzalloc usage. Compile tested with allyesconfig.
drivers/media/dvb/cinergyT2/cinergyT2.c renamed from drivers/media/dvb/cinergyT2/cinergyT2.c.orig +1 -2
@@ -877,12 +877,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);init_MUTEX (&cinergyt2->sem);
drivers/media/video/cx88/cx88-alsa.c renamed from drivers/media/video/cx88/cx88-alsa.c.orig +1 -3
@@ -413,11 +413,9 @@ static int snd_cx88_hw_params(struct snddprintk (1 ,"Setting buffer\n" ); - buf =kmalloc (sizeof (*buf),GFP_KERNEL ); + buf =kzalloc (sizeof (*buf),GFP_KERNEL );if (NULL == buf)return -ENOMEM ; -memset (buf,0 ,sizeof (*buf)); - buf->vb.memory =V4L2_MEMORY_MMAP ; buf->vb.width = chip->period_size;
drivers/media/video/msp3400-driver.c renamed from drivers/media/video/msp3400-driver.c.orig +2 -4
@@ -1070,10 +1070,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;
@@ -1085,14 +1084,13 @@ static int msp_attach(struct i2c_adapterreturn -1 ; } - state =kmalloc (sizeof (*state),GFP_KERNEL ); + state =kzalloc (sizeof (*state),GFP_KERNEL );if (state ==NULL ) {kfree (client);return -ENOMEM ; }i2c_set_clientdata (client, state); -memset (state,0 ,sizeof (*state)); state->v4l2_std =V4L2_STD_NTSC ; state->volume =58880 ;/* 0db gain */ state->balance =32768 ;/* 0db gain */
drivers/media/video/planb.c renamed from drivers/media/video/planb.c.orig +1 -2
@@ -352,9 +352,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;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/block
In reply to Eric Sesterhennhi,
this patch converts drivers/block to kzalloc usage. Compile tested with allyesconfig.
drivers/block/paride/bpck6.c renamed from drivers/block/paride/bpck6.c.orig +1 -2
@@ -224,10 +224,9 @@ static void bpck6_log_adapter( PIA *pi,static int bpck6_init_proto (PIA *pi) { -Interface *p =kmalloc (sizeof (Interface),GFP_KERNEL ); +Interface *p =kzalloc (sizeof (Interface),GFP_KERNEL );if (p) { -memset (p,0 ,sizeof (Interface)); pi->private = (unsigned long )p;return 0 ; }
drivers/block/cciss_scsi.c renamed from drivers/block/cciss_scsi.c.orig +1 -2
@@ -1027,12 +1027,11 @@ cciss_update_non_disk_devices(int cntl_nint i; c = (ctlr_info_t *) hba[cntl_num]; - ld_buff =kmalloc (reportlunsize,GFP_KERNEL ); + ld_buff =kzalloc (reportlunsize,GFP_KERNEL );if (ld_buff ==NULL ) {printk (KERN_ERR "cciss: out of memory\n" );return ; } -memset (ld_buff,0 , reportlunsize); inq_buff =kmalloc (OBDR_TAPE_INQ_SIZE ,GFP_KERNEL );if (inq_buff ==NULL ) {printk (KERN_ERR "cciss: out of memory\n" );
drivers/block/cciss.c renamed from drivers/block/cciss.c.orig +3 -7
@@ -996,13 +996,11 @@ static int cciss_ioctl(struct inode *ino status = -EINVAL ; goto cleanup1; } - buff = (unsigned char **)kmalloc (MAXSGENTRIES * -sizeof (char *),GFP_KERNEL ); + buff =kzalloc (MAXSGENTRIES *sizeof (char *),GFP_KERNEL );if (!buff) { status = -ENOMEM ; goto cleanup1; } -memset (buff,0 ,MAXSGENTRIES ); buff_size = (int *)kmalloc (MAXSGENTRIES *sizeof (int ),GFP_KERNEL );if (!buff_size) {
@@ -2941,13 +2939,12 @@ static void cciss_getgeometry(int cntl_nint block_size;int total_size; - ld_buff =kmalloc (sizeof (ReportLunData_struct),GFP_KERNEL ); + ld_buff =kzalloc (sizeof (ReportLunData_struct),GFP_KERNEL );if (ld_buff ==NULL ) {printk (KERN_ERR "cciss: out of memory\n" );return ; } -memset (ld_buff,0 ,sizeof (ReportLunData_struct)); size_buff =kmalloc (sizeof ( ReadCapdata_struct),GFP_KERNEL );if (size_buff ==NULL ) {
@@ -3061,10 +3058,9 @@ static int alloc_cciss_hba(void)for (i=0 ; i<MAX_CTLR ; i++) {if (!hba[i]) {ctlr_info_t *p; - p =kmalloc (sizeof (ctlr_info_t),GFP_KERNEL ); + p =kzalloc (sizeof (ctlr_info_t),GFP_KERNEL );if (!p) goto Enomem; -memset (p,0 ,sizeof (ctlr_info_t));for (n =0 ; n <NWD ; n++) p->gendisk[n] = disk[n]; hba[i] = p;
drivers/block/DAC960.c renamed from drivers/block/DAC960.c.orig +2 -5
@@ -312,11 +312,10 @@ static boolean DAC960_CreateAuxiliaryStr CommandsRemaining = CommandAllocationGroupSize; CommandGroupByteCount = CommandsRemaining * CommandAllocationLength; - AllocationPointer =kmalloc (CommandGroupByteCount,GFP_ATOMIC ); + AllocationPointer =kzalloc (CommandGroupByteCount,GFP_ATOMIC );if (AllocationPointer ==NULL )return DAC960_Failure (Controller,"AUXILIARY STRUCTURE CREATION" ); -memset (AllocationPointer,0 , CommandGroupByteCount); } Command = (DAC960_Command_T *) AllocationPointer; AllocationPointer += CommandAllocationLength;
@@ -2710,14 +2709,12 @@ DAC960_DetectController(struct pci_dev *void __iomem *BaseAddress;int i; - Controller = (DAC960_Controller_T *) -kmalloc (sizeof (DAC960_Controller_T),GFP_ATOMIC ); + Controller =kzalloc (sizeof (DAC960_Controller_T),GFP_ATOMIC );if (Controller ==NULL ) {DAC960_Error ("Unable to allocate Controller structure for " "Controller at\n" ,NULL );return NULL ; } -memset (Controller,0 ,sizeof (DAC960_Controller_T)); Controller->ControllerNumber = DAC960_ControllerCount; DAC960_Controllers[DAC960_ControllerCount++] = Controller; Controller->Bus = PCI_Device->bus->number;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/sh
In reply to Eric Sesterhennhi,
this patch converts drivers/sh/ to kzalloc usage.
Compile tested with allyesconfig.
drivers/sh/superhyway/superhyway.c renamed from drivers/sh/superhyway/superhyway.c.orig +1 -3
@@ -56,11 +56,9 @@ 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;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/pnp
In reply to Eric Sesterhennhi,
this patch converts drivers/pnp/ to kzalloc usage. Compile tested with allyesconfig.
drivers/pnp/core.c renamed from drivers/pnp/core.c.orig +1 -2
@@ -26,12 +26,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; }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/nubus
In reply to Eric Sesterhennhi,
this patch converts drivers/nubus/ to kzalloc usage. Not tested.
drivers/nubus/nubus.c renamed from drivers/nubus/nubus.c.orig +2 -4
@@ -467,9 +467,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;
@@ -801,9 +800,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 */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/message
In reply to Eric Sesterhennhi,
this patch converts drivers/message/ to kzalloc usage. Compile tested with allyesconfig.
drivers/message/fusion/mptctl.c renamed from drivers/message/fusion/mptctl.c.orig +4 -8
@@ -962,10 +962,9 @@ kbuf_alloc_2_sgl(int bytes, u32 sgdir, i* structures for the SG elements. */ i =MAX_SGL_BYTES /8 ; - buflist =kmalloc (i,GFP_USER ); + buflist =kzalloc (i,GFP_USER );if (buflist ==NULL )return NULL ; -memset (buflist,0 , i); buflist_ent =0 ;/* Allocate a single block of memory to store the sg elements and
@@ -1377,13 +1376,12 @@ mptctl_gettargetinfo (unsigned long arg)* 15- 8: Bus Number * 7- 0: Target ID */ - pmem =kmalloc (numBytes,GFP_KERNEL ); + pmem =kzalloc (numBytes,GFP_KERNEL );if (pmem ==NULL ) {printk (KERN_ERR "%s::mptctl_gettargetinfo() @%d - no memory available!\n" , __FILE__, __LINE__);return -ENOMEM ; } -memset (pmem,0 , numBytes); pdata = (int *) pmem;/* Get number of devices
@@ -1617,12 +1615,11 @@ mptctl_eventenable (unsigned long arg)/* Have not yet allocated memory - do so now. */ int sz =MPTCTL_EVENT_LOG_SIZE *sizeof (MPT_IOCTL_EVENTS ); - ioc->events =kmalloc (sz,GFP_KERNEL ); + ioc->events =kzalloc (sz,GFP_KERNEL );if (ioc->events ==NULL ) { printk(KERN_ERR MYNAM ": ERROR - Insufficient memory to add adapter!\n");return -ENOMEM ; } -memset (ioc->events,0 , sz); ioc->alloc_total += sz; ioc->eventContext =0 ;
@@ -2888,13 +2885,12 @@ mptctl_probe(struct pci_dev *pdev, const* Allocate and inite a MPT_IOCTL structure */ sz =sizeof (MPT_IOCTL ); - mem =kmalloc (sz,GFP_KERNEL ); + mem =kzalloc (sz,GFP_KERNEL );if (mem ==NULL ) { err = -ENOMEM ; goto out_fail; } -memset (mem,0 , sz); ioc->ioctl = (MPT_IOCTL *) mem; ioc->ioctl->ioc = ioc;mutex_init (&ioc->ioctl->ioctl_mutex);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/mca
In reply to Eric Sesterhennhi,
this patch converts drivers/mca/ to kzalloc usage. Compile tested with allyesconfig.
drivers/mca/mca-bus.c renamed from drivers/mca/mca-bus.c.orig +1 -2
@@ -157,10 +157,9 @@ struct mca_bus * __devinit mca_attach_bureturn NULL ; } - mca_bus =kmalloc (sizeof (struct mca_bus ),GFP_KERNEL ); + mca_bus =kzalloc (sizeof (struct mca_bus ),GFP_KERNEL );if (!mca_bus)return NULL ; -memset (mca_bus,0 ,sizeof (struct mca_bus ));sprintf (mca_bus->dev.bus_id,"mca%d" ,bus);sprintf (mca_bus->name,"Host %s MCA Bridge" , bus ?"Secondary" :"Primary" );device_register (&mca_bus->dev);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/acorn/
In reply to Eric Sesterhennhi,
this patch converts drivers/acorn/ to kzalloc usage. Compile tested with allyesconfig.
drivers/acorn/char/pcf8583.c renamed from drivers/acorn/char/pcf8583.c.orig +1 -2
@@ -55,11 +55,10 @@ pcf8583_attach(struct i2c_adapter *adap, } }; - c =kmalloc (sizeof (*c),GFP_KERNEL ); + c =kzalloc (sizeof (*c),GFP_KERNEL );if (!c)return -ENOMEM ; -memset (c,0 ,sizeof (*c)); c->addr = addr; c->adapter = adap; c->driver = &pcf8583_driver;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 kzalloc() conversion in drivers/parport/
In reply to Eric Sesterhennhi,
this patch converts crypto/ to kzalloc usage.
Compile tested with allyesconfig.
drivers/parport/parport_serial.c renamed from drivers/parport/parport_serial.c.orig +1 -2
@@ -368,10 +368,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/parport/parport_cs.c renamed from drivers/parport/parport_cs.c.orig +1 -2
@@ -106,9 +106,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;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors