ioremap balanced with iounmap for drivers/mtd subsystem
Subsystems (17)
PATCH 1/1 ioremap balanced with iounmap for drivers/mtd subsystem
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
- Modifying drivers/mtd/maps/Kconfig and drivers/mtd/nand/Kconfig to make sure that the changed file is compiling without warning
---
I'm not subsribed to linux-mtd so please cc me.
--- drivers/mtd/maps/arctic-mtd.c | 14 ++++++++++++-- drivers/mtd/maps/beech-mtd.c | 14 ++++++++++++-- drivers/mtd/maps/cstm_mips_ixx.c | 18 ++++++++++++++++-- drivers/mtd/maps/ebony.c | 4 ++++ drivers/mtd/maps/fortunet.c | 3 +++ drivers/mtd/maps/lasat.c | 2 ++ drivers/mtd/maps/nettel.c | 34 +++++++++++++++++++++++++++------- drivers/mtd/maps/ocotea.c | 4 ++++ drivers/mtd/maps/pcmciamtd.c | 4 ++++ drivers/mtd/maps/redwood.c | 11 ++++++++++- drivers/mtd/maps/sbc8240.c | 11 ++++++++++- drivers/mtd/maps/walnut.c | 4 ++++ drivers/mtd/nand/edb7312.c | 3 +++ drivers/mtd/nand/ppchameleonevb.c | 7 +++++++ include/linux/utsrelease.h | 1 + 15 files changed, 119 insertions(+), 15 deletions(-)
---
drivers/mtd/maps/arctic-mtd.c +12 -2
@@ -96,6 +96,8 @@ static struct mtd_partition arctic_partistatic int __init init_arctic_mtd (void ) { +int err =0 ; +printk ("%s: 0x%08x at 0x%08x\n" ,NAME ,SIZE ,PADDR ); arctic_mtd_map.virt =ioremap (PADDR ,SIZE );
@@ -109,12 +111,20 @@ init_arctic_mtd(void)printk ("%s: probing %d-bit flash bus\n" ,NAME ,BUSWIDTH *8 ); arctic_mtd =do_map_probe ("cfi_probe" , &arctic_mtd_map); -if (!arctic_mtd) +if (!arctic_mtd) { +iounmap ((void *) arctic_mtd_map.virt);return -ENXIO ; + } arctic_mtd->owner =THIS_MODULE ; -return add_mtd_partitions (arctic_mtd, arctic_partitions,PARTITIONS ); + err =add_mtd_partitions (arctic_mtd, arctic_partitions,PARTITIONS ); +if (err) { +printk ("%s: add_mtd_partitions failed\n" ,NAME ); +iounmap ((void *) arctic_mtd_map.virt); + } + +return err; }static void __exit
drivers/mtd/maps/beech-mtd.c +12 -2
@@ -72,6 +72,8 @@ static struct mtd_partition beech_partitstatic int __init init_beech_mtd (void ) { +int err =0 ; +printk ("%s: 0x%08x at 0x%08x\n" ,NAME ,SIZE ,PADDR ); beech_mtd_map.virt =ioremap (PADDR ,SIZE );
@@ -86,12 +88,20 @@ init_beech_mtd(void)printk ("%s: probing %d-bit flash bus\n" ,NAME ,BUSWIDTH *8 ); beech_mtd =do_map_probe ("cfi_probe" , &beech_mtd_map); -if (!beech_mtd) +if (!beech_mtd) { +iounmap ((void *) beech_mtd_map.virt);return -ENXIO ; + } beech_mtd->owner =THIS_MODULE ; -return add_mtd_partitions (beech_mtd, beech_partitions,2 ); + err =add_mtd_partitions (beech_mtd, beech_partitions,2 ); +if (err) { +printk ("%s: add_mtd_partitions failed\n" ,NAME ); +iounmap ((void *) beech_mtd_map.virt); + } + +return err; }static void __exit
drivers/mtd/maps/cstm_mips_ixx.c +16 -2
@@ -171,7 +171,14 @@ int __init init_cstm_mips_ixx(void) cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr; cstm_mips_ixx_map[i].virt =ioremap (cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size);if (!cstm_mips_ixx_map[i].virt) { +int j =0 ;printk (KERN_WARNING "Failed to ioremap\n" ); +for (j =0 ; j < i; j++) { +if (cstm_mips_ixx_map[j].virt) { +iounmap ((void *)cstm_mips_ixx_map[j].virt); + cstm_mips_ixx_map[j].virt =0 ; + } + }return -EIO ; } cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name;
@@ -204,8 +211,15 @@ int __init init_cstm_mips_ixx(void) cstm_mips_ixx_map[i].map_priv_2 = (unsigned long )mymtd;add_mtd_partitions (mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions); } -else -return -ENXIO ; +else { +for (i =0 ; i <PHYSMAP_NUMBER ; i++) { +if (cstm_mips_ixx_map[i].virt) { +iounmap ((void *)cstm_mips_ixx_map[i].virt); + cstm_mips_ixx_map[i].virt =0 ; + } + } +return -ENXIO ; + } }return 0 ; }
drivers/mtd/maps/ebony.c +4 -0
@@ -108,6 +108,7 @@ int __init init_ebony(void) ARRAY_SIZE(ebony_small_partitions)); }else {printk ("map probe failed for flash\n" ); +iounmap (ebony_small_map.virt);return -ENXIO ; }
@@ -117,6 +118,7 @@ int __init init_ebony(void)if (!ebony_large_map.virt) {printk ("Failed to ioremap flash\n" ); +iounmap (ebony_small_map.virt);return -EIO ; }
@@ -129,6 +131,8 @@ int __init init_ebony(void) ARRAY_SIZE(ebony_large_partitions)); }else {printk ("map probe failed for flash\n" ); +iounmap (ebony_small_map.virt); +iounmap (ebony_large_map.virt);return -ENXIO ; }
drivers/mtd/maps/fortunet.c +3 -0
@@ -218,8 +218,11 @@ int __init init_fortunet(void) map_regions[ix].map_info.size);if (!map_regions[ix].map_info.virt) { +int j =0 ;printk (MTD_FORTUNET_PK "%s flash failed to ioremap!\n" , map_regions[ix].map_info.name); +for (j =0 ; j < ix; j++) +iounmap (map_regions[j].map_info.virt);return -ENXIO ; }simple_map_init (&map_regions[ix].map_info);
drivers/mtd/maps/lasat.c +2 -0
@@ -79,6 +79,7 @@ static int __init init_lasat(void)return 0 ; } +iounmap (lasat_map.virt);return -ENXIO ; }
@@ -89,6 +90,7 @@ static void __exit cleanup_lasat(void)map_destroy (lasat_mtd); }if (lasat_map.virt) { +iounmap (lasat_map.virt); lasat_map.virt =0 ; } }
drivers/mtd/maps/nettel.c +27 -7
@@ -277,6 +277,7 @@ int __init nettel_init(void) nettel_amd_map.virt =ioremap_nocache (amdaddr, maxsize);if (!nettel_amd_map.virt) {printk ("SNAPGEAR: failed to ioremap() BOOTCS\n" ); +iounmap (nettel_mmcrp);return (-EIO ); }simple_map_init (&nettel_amd_map);
@@ -337,7 +338,8 @@ int __init nettel_init(void) nettel_amd_map.virt =NULL ;#else /* Only AMD flash supported */ -return (-ENXIO ); + rc = -ENXIO ; + goto out_unmap2;#endif }
@@ -361,14 +363,15 @@ int __init nettel_init(void) nettel_intel_map.virt =ioremap_nocache (intel0addr, maxsize);if (!nettel_intel_map.virt) {printk ("SNAPGEAR: failed to ioremap() ROMCS1\n" ); -return (-EIO ); + rc = -EIO ; + goto out_unmap2; }simple_map_init (&nettel_intel_map); intel_mtd =do_map_probe ("cfi_probe" , &nettel_intel_map);if (!intel_mtd) { -iounmap (nettel_intel_map.virt); -return (-ENXIO ); + rc = -ENXIO ; + goto out_unmap1; }/* Set PAR to the detected size */
@@ -394,13 +397,14 @@ int __init nettel_init(void) nettel_intel_map.virt =ioremap_nocache (intel0addr, maxsize);if (!nettel_intel_map.virt) {printk ("SNAPGEAR: failed to ioremap() ROMCS1/2\n" ); -return (-EIO ); + rc = -EIO ; + goto out_unmap2; } intel_mtd =do_map_probe ("cfi_probe" , &nettel_intel_map);if (! intel_mtd) { -iounmap ((void *) nettel_intel_map.virt); -return (-ENXIO ); + rc = -ENXIO ; + goto out_unmap1; } intel1size = intel_mtd->size - intel0size;
@@ -456,6 +460,18 @@ int __init nettel_init(void)#endif return (rc); + +#ifdef CONFIG_MTD_CFI_INTELEXT +out_unmap1: +iounmap ((void *) nettel_intel_map.virt); +#endif + +out_unmap2: +iounmap (nettel_mmcrp); +iounmap (nettel_amd_map.virt); + +return (rc); + }/****************************************************************************/
@@ -469,6 +485,10 @@ void __exit nettel_cleanup(void)del_mtd_partitions (amd_mtd);map_destroy (amd_mtd); } +if (nettel_mmcrp) { +iounmap (nettel_mmcrp); + nettel_mmcrp =NULL ; + }if (nettel_amd_map.virt) {iounmap (nettel_amd_map.virt); nettel_amd_map.virt =NULL ;
drivers/mtd/maps/ocotea.c +4 -0
@@ -97,6 +97,7 @@ int __init init_ocotea(void) ARRAY_SIZE(ocotea_small_partitions)); }else {printk ("map probe failed for flash\n" ); +iounmap (ocotea_small_map.virt);return -ENXIO ; }
@@ -106,6 +107,7 @@ int __init init_ocotea(void)if (!ocotea_large_map.virt) {printk ("Failed to ioremap flash\n" ); +iounmap (ocotea_small_map.virt);return -EIO ; }
@@ -118,6 +120,8 @@ int __init init_ocotea(void) ARRAY_SIZE(ocotea_large_partitions)); }else {printk ("map probe failed for flash\n" ); +iounmap (ocotea_small_map.virt); +iounmap (ocotea_large_map.virt);return -ENXIO ; }
drivers/mtd/maps/pcmciamtd.c +4 -0
@@ -602,6 +602,10 @@ static int pcmciamtd_config(struct pcmci ret =pcmcia_request_configuration (link, &link->conf);if (ret !=CS_SUCCESS ) {cs_error (link, RequestConfiguration, ret); +if (dev->win_base) { +iounmap (dev->win_base); + dev->win_base =NULL ; + }return -ENODEV ; }
drivers/mtd/maps/redwood.c +10 -1
@@ -126,6 +126,8 @@ static struct mtd_info *redwood_mtd;int __init init_redwood_flash (void ) { +int err =0 ; +printk (KERN_NOTICE "redwood: flash mapping: %x at %x\n" ,WINDOW_SIZE ,WINDOW_ADDR );
@@ -141,11 +143,18 @@ int __init init_redwood_flash(void)if (redwood_mtd) { redwood_mtd->owner =THIS_MODULE ; -return add_mtd_partitions (redwood_mtd, + err =add_mtd_partitions (redwood_mtd, redwood_flash_partitions,NUM_REDWOOD_FLASH_PARTITIONS ); +if (err) { +printk ("init_redwood_flash: add_mtd_partitions failed\n" ); +iounmap (redwood_flash_map.virt); + } +return err; + } +iounmap (redwood_flash_map.virt);return -ENXIO ; }
drivers/mtd/maps/sbc8240.c +10 -1
@@ -156,7 +156,7 @@ int __init init_sbc8240_mtd (void) };int devicesfound =0 ; -int i; +int i,j;for (i =0 ; i <NUM_FLASH_BANKS ; i++) { printk (KERN_NOTICE MSG_PREFIX
@@ -166,6 +166,10 @@ int __init init_sbc8240_mtd (void) (unsigned long )ioremap (pt[i].addr, pt[i].size);if (!sbc8240_map[i].map_priv_1) {printk (MSG_PREFIX "failed to ioremap\n" ); +for (j =0 ; j < i; j++) { +iounmap ((void *) sbc8240_map[j].map_priv_1); + sbc8240_map[j].map_priv_1 =0 ; + }return -EIO ; }simple_map_init (&sbc8240_mtd[i]);
@@ -175,6 +179,11 @@ int __init init_sbc8240_mtd (void)if (sbc8240_mtd[i]) { sbc8240_mtd[i]->module =THIS_MODULE ; devicesfound++; + }else { +if (sbc8240_map[i].map_priv_1) { +iounmap ((void *) sbc8240_map[i].map_priv_1); + sbc8240_map[i].map_priv_1 =0 ; + } } }
drivers/mtd/maps/walnut.c +4 -0
@@ -68,6 +68,7 @@ int __init init_walnut(void)if (WALNUT_FLASH_ONBD_N (fpga_brds1)) {printk ("The on-board flash is disabled (U79 sw 5)!" ); +iounmap (fpga_status_adr);return -EIO ; }if (WALNUT_FLASH_SRAM_SEL (fpga_brds1))
@@ -81,6 +82,7 @@ int __init init_walnut(void)if (!walnut_map.virt) {printk ("Failed to ioremap flash.\n" ); +iounmap (fpga_status_adr);return -EIO ; }
@@ -93,9 +95,11 @@ int __init init_walnut(void) ARRAY_SIZE(walnut_partitions)); }else {printk ("map probe failed for flash\n" ); +iounmap (fpga_status_adr);return -ENXIO ; } +iounmap (fpga_status_adr);return 0 ; }
drivers/mtd/nand/edb7312.c +3 -0
@@ -198,6 +198,9 @@ static void __exit ep7312_cleanup(void)/* Release resources, unregister device */ nand_release (ap7312_mtd); +/* Release io resource */ +iounmap ((void *)this->IO_ADDR_R); +/* Free the MTD device structure */ kfree (ep7312_mtd); }
drivers/mtd/nand/ppchameleonevb.c +7 -0
@@ -276,6 +276,7 @@ static int __init ppchameleonevb_init(vo/* Scan to find existence of the device (it could not be mounted) */ if (nand_scan (ppchameleon_mtd,1 )) {iounmap ((void *)ppchameleon_fio_base); + ppchameleon_fio_base =NULL ;kfree (ppchameleon_mtd); goto nand_evb_init; }
@@ -314,6 +315,8 @@ static int __init ppchameleonevb_init(vo ppchameleonevb_mtd =kmalloc (sizeof (struct mtd_info ) +sizeof (struct nand_chip ),GFP_KERNEL );if (!ppchameleonevb_mtd) {printk ("Unable to allocate PPChameleonEVB NAND MTD device structure.\n" ); +if (ppchameleon_fio_base) +iounmap (ppchameleon_fio_base);return -ENOMEM ; }
@@ -322,6 +325,8 @@ static int __init ppchameleonevb_init(voif (!ppchameleonevb_fio_base) {printk ("ioremap PPChameleonEVB NAND flash failed\n" );kfree (ppchameleonevb_mtd); +if (ppchameleon_fio_base) +iounmap (ppchameleon_fio_base);return -EIO ; }
@@ -378,6 +383,8 @@ static int __init ppchameleonevb_init(voif (nand_scan (ppchameleonevb_mtd,1 )) {iounmap ((void *)ppchameleonevb_fio_base);kfree (ppchameleonevb_mtd); +if (ppchameleon_fio_base) +iounmap (ppchameleon_fio_base);return -ENXIO ; }#ifdef CONFIG_MTD_PARTITIONS
include/linux/utsrelease.h +1 -0
@@ -0,0 +1 @@ +#define UTS_RELEASE "2.6.18"
PATCH 1/1 ioremap balanced with iounmap for drivers/scsi
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
- Modifying drivers/scsi/Kconfig to make sure that the changed file is compiling without warning
---
Please CC me as I'm not subscribed to linux-scsi
--- 3w-9xxx.c | 5 +++++ amiga7xx.c | 2 ++ fdomain.c | 6 +++++- ncr53c8xx.c | 2 ++ nsp32.c | 5 +++++ qlogicpti.c | 1 + seagate.c | 13 ++++++++++++- sun3_scsi.c | 7 ++++++- sun3_scsi_vme.c | 5 ++++- zalon.c | 2 ++ 10 files changed, 44 insertions(+), 4 deletions(-)
---
drivers/scsi/3w-9xxx.c +5 -0
@@ -2147,6 +2147,8 @@ out_remove_host:scsi_remove_host (host); out_release_mem_region:pci_release_regions (pdev); +if (tw_dev->base_addr) +iounmap (tw_dev->base_addr); out_free_device_extension:twa_free_device_extension (tw_dev);scsi_host_put (host);
@@ -2173,6 +2175,9 @@ static void twa_remove(struct pci_dev *p/* Free up the IRQ */ free_irq (tw_dev->tw_pci_dev->irq, tw_dev); +/* Free IO mem */ +iounmap (tw_dev->base_addr); +/* Shutdown the card */ __twa_shutdown (tw_dev);
drivers/scsi/amiga7xx.c +2 -0
@@ -115,6 +115,8 @@ static int amiga7xx_release(struct Scsi_free_irq (shost->irq,NULL );if (shost->dma_channel !=0xff )free_dma (shost->dma_channel); +if (shost->base) +z_iounmap ((void *)shost->base);if (shost->io_port && shost->n_io_port)release_region (shost->io_port, shost->n_io_port);scsi_unregister (shost);
drivers/scsi/fdomain.c +5 -1
@@ -780,7 +780,11 @@ found: else printk( " FAILURE\n" );#endif -if (!flag)return 0 ;/* iobase not found */ +if (!flag) { +if (bios_mem) +iounmap (bios_mem); +return 0 ;/* iobase not found */ + } *irq =fdomain_get_irq ( base ); *iobase = base;
drivers/scsi/ncr53c8xx.c +2 -0
@@ -8563,6 +8563,8 @@ struct Scsi_Host * __init ncr_attach(strm_free_dma (np->script0,sizeof (struct script ),"SCRIPT" );if (np->ccb)m_free_dma (np->ccb,sizeof (struct ccb ),"CCB" ); +if (!device->slot.base_v && np->vaddr) +iounmap (np->vaddr);m_free_dma (np,sizeof (struct ncb ),"NCB" ); host_data->ncb =NULL ;
drivers/scsi/nsp32.c +5 -0
@@ -3540,6 +3540,11 @@ static int __devinit nsp32_probe(structnsp32_dbg (NSP32_DEBUG_REGISTER ,"exit %d" , ret); +if (ret) { +iounmap (data->MmioAddress); + data->MmioAddress =NULL ; + } +return ret; }
drivers/scsi/qlogicpti.c +1 -0
@@ -699,6 +699,7 @@ static int __init qpti_map_regs(struct q "PTI Qlogic/ISP statreg");if (!qpti->sreg) {printk ("PTI: Qlogic/ISP status register is unmappable\n" ); +sbus_iounmap (qpti->qregs, qpti->sdev->reg_addrs[0 ].reg_size);return -1 ; } }
drivers/scsi/seagate.c +12 -1
@@ -493,12 +493,19 @@ int __init seagate_st0x_detect (struct s* if we lose our first interrupt. */ instance =scsi_register (tpnt,0 ); -if (instance ==NULL ) +if (instance ==NULL ) { +iounmap (st0x_cr_sr); +iounmap (st0x_dr); + st0x_cr_sr = st0x_dr =NULL ;return 0 ; + } hostno = instance->host_no;if (request_irq (irq, do_seagate_reconnect_intr,IRQF_DISABLED , (controller_type ==SEAGATE ) ?"seagate" :"tmc-8xx" , instance)) {printk (KERN_ERR "scsi%d : unable to allocate IRQ%d\n" , hostno, irq); +iounmap (st0x_cr_sr); +iounmap (st0x_dr); + st0x_cr_sr = st0x_dr =NULL ;return 0 ; } instance->irq = irq;
@@ -1645,6 +1652,10 @@ static int seagate_st0x_release(struct S {if (shost->irq)free_irq (shost->irq, shost); +if (st0x_cr_sr) +iounmap (st0x_cr_sr); +if (st0x_dr) +iounmap (st0x_dr);release_region (shost->io_port, shost->n_io_port);return 0 ; }
drivers/scsi/sun3_scsi.c +6 -1
@@ -240,11 +240,13 @@ int sun3scsi_detect(struct scsi_host_temif ((udc_regs =dvma_malloc (sizeof (struct sun3_udc_regs ))) ==NULL ) {printk ("SUN3 Scsi couldn't allocate DVMA memory!\n" ); +iounmap ((void *)ioaddr);return 0 ; }#ifdef OLDDMA if ((dmabuf =dvma_malloc_align (SUN3_DVMA_BUFSIZE ,0x10000 )) ==NULL ) {printk ("SUN3 Scsi couldn't allocate DVMA memory!\n" ); +iounmap ((void *)ioaddr);return 0 ; }#endif
@@ -254,8 +256,10 @@ int sun3scsi_detect(struct scsi_host_tem#endif instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); -if (instance ==NULL ) +if (instance ==NULL ) { +iounmap ((void *)ioaddr);return 0 ; + } default_instance = instance;
@@ -277,6 +281,7 @@ int sun3scsi_detect(struct scsi_host_tem#else printk ("scsi%d: IRQ%d not free, bailing out\n" , instance->host_no, instance->irq); +iounmap ((void *)ioaddr);return 0 ;#endif }
drivers/scsi/sun3_scsi_vme.c +4 -1
@@ -216,8 +216,10 @@ static int sun3scsi_detect(struct scsi_h#endif instance =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); -if (instance ==NULL ) +if (instance ==NULL ) { +iounmap ((void *)ioaddr);return 0 ; + } default_instance = instance;
@@ -239,6 +241,7 @@ static int sun3scsi_detect(struct scsi_h#else printk ("scsi%d: IRQ%d not free, bailing out\n" , instance->host_no, instance->irq); +iounmap ((void *)ioaddr);return 0 ;#endif }
drivers/scsi/zalon.c +2 -0
@@ -156,6 +156,8 @@ zalon_probe(struct parisc_device *dev) fail_free_irq:free_irq (dev->irq, host); fail: +if (zalon) +iounmap (zalon);ncr53c8xx_release (host);return error; }
PATCH 1/1 ioremap balanced with iounmap for drivers/isdn
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
--- hisax/diva.c | 26 ++++++++++++++++++++++++-- hysdn/boardergo.c | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-)
---
drivers/isdn/hisax/diva.c +24 -2
@@ -716,8 +716,10 @@ release_io_diva(struct IsdnCardState *cs *cfg =0 ;/* disable INT0/1 */ *cfg =2 ;/* reset pending INT0 */ -iounmap ((void *)cs->hw.diva.cfg_reg); -iounmap ((void *)cs->hw.diva.pci_cfg); +if (cs->hw.diva.cfg_reg) +iounmap ((void *)cs->hw.diva.cfg_reg); +if (cs->hw.diva.pci_cfg) +iounmap ((void *)cs->hw.diva.pci_cfg);return ; }else if (cs->subtyp !=DIVA_IPAC_ISA ) {del_timer (&cs->hw.diva.tl);
@@ -734,6 +736,23 @@ release_io_diva(struct IsdnCardState *cs }static void +iounmap_diva (struct IsdnCardState *cs) +{ +if ((cs->subtyp =DIVA_IPAC_PCI ) || (cs->subtyp =DIVA_IPACX_PCI )) { +if (cs->hw.diva.cfg_reg) { +iounmap ((void *)cs->hw.diva.cfg_reg); + cs->hw.diva.cfg_reg =0 ; + } +if (cs->hw.diva.pci_cfg) { +iounmap ((void *)cs->hw.diva.pci_cfg); + cs->hw.diva.pci_cfg =0 ; + } + } + +return ; +} + +static void reset_diva (struct IsdnCardState *cs) {if (cs->subtyp =DIVA_IPAC_ISA ) {
@@ -1069,11 +1088,13 @@ setup_diva(struct IsdnCard *card)if (!cs->irq) {printk (KERN_WARNING "Diva: No IRQ for PCI card found\n" ); +iounmap_diva (cs);return (0 ); }if (!cs->hw.diva.cfg_reg) {printk (KERN_WARNING "Diva: No IO-Adr for PCI card found\n" ); +iounmap_diva (cs);return (0 ); } cs->irq_flags |=IRQF_SHARED ;
@@ -1123,6 +1144,7 @@ ready: CardType[card->typ], cs->hw.diva.cfg_reg, cs->hw.diva.cfg_reg + bytecnt); +iounmap_diva (cs);return (0 ); } }
drivers/isdn/hysdn/boardergo.c +1 -1
@@ -408,7 +408,7 @@ ergo_releasehardware(hysdn_card * card)free_irq (card->irq, card);/* release interrupt */ release_region (card->iobase +PCI9050_INTR_REG ,1 );/* release all io ports */ release_region (card->iobase +PCI9050_USER_IO ,1 ); -vfree (card->dpram); +iounmap (card->dpram); card->dpram =NULL ;/* release shared mem */ }/* ergo_releasehardware */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for drivers/serial
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- Modifying drivers/serial/Kconfig to make sure that the changed file is compiling without error/warning (due to my changes)
---
Please cc me. I'm not on linux-serial
--- 8250_acorn.c | 9 +++++---- 8250_gsc.c | 1 + ioc4_serial.c | 3 +++ ip22zilog.c | 16 +++++++++++++++- mpc52xx_uart.c | 11 ++++++++++- mpsc.c | 12 ++++++++++++ mux.c | 2 ++ sunsu.c | 3 +++ 8 files changed, 51 insertions(+), 6 deletions(-)
---
drivers/serial/8250_acorn.c +5 -4
@@ -35,6 +35,7 @@ struct serial_card_type {struct serial_card_info {unsigned int num_ports;int ports[MAX_PORTS ]; +void __iomem *vaddr; }; static int __devinit
@@ -44,7 +45,6 @@ serial_card_probe(struct expansion_cardstruct serial_card_type *type = id->data;struct uart_port port;unsigned long bus_addr; -unsigned char __iomem *virt_addr;unsigned int i; info =kmalloc (sizeof (struct serial_card_info ),GFP_KERNEL );
@@ -55,8 +55,8 @@ serial_card_probe(struct expansion_card info->num_ports = type->num_ports; bus_addr =ecard_resource_start (ec, type->type); - virt_addr =ioremap (bus_addr,ecard_resource_len (ec, type->type)); -if (!virt_addr) { + info->vaddr =ioremap (bus_addr,ecard_resource_len (ec, type->type)); +if (!info->vaddr) {kfree (info);return -ENOMEM ; }
@@ -72,7 +72,7 @@ serial_card_probe(struct expansion_card port.dev = &ec->dev;for (i =0 ; i < info->num_ports; i ++) { - port.membase = virt_addr + type->offset[i]; + port.membase = info->vaddr + type->offset[i]; port.mapbase = bus_addr + type->offset[i]; info->ports[i] =serial8250_register_port (&port);
@@ -92,6 +92,7 @@ static void __devexit serial_card_removeif (info->ports[i] >0 )serial8250_unregister_port (info->ports[i]); +iounmap (info->vaddr);kfree (info); }
drivers/serial/8250_gsc.c +1 -0
@@ -64,6 +64,7 @@ serial_init_chip(struct parisc_device *d err =serial8250_register_port (&port);if (err <0 ) {printk (KERN_WARNING "serial8250_register_port returned error %d\n" , err); +iounmap (port.membase);return err; }
drivers/serial/ioc4_serial.c +3 -0
@@ -2685,6 +2685,7 @@ static int ioc4_serial_remove_one(structif (soft) {free_irq (control->ic_irq, soft);if (soft->is_ioc4_serial_addr) { +iounmap (soft->is_ioc4_serial_addr);release_region ((unsigned long ) soft->is_ioc4_serial_addr,sizeof (struct ioc4_serial ));
@@ -2887,6 +2888,8 @@ out4: out3:kfree (control); out2: +if (serial) +iounmap (serial);release_region (tmp_addr1,sizeof (struct ioc4_serial )); out1:
drivers/serial/ip22zilog.c +15 -1
@@ -1229,13 +1229,27 @@ static int __init ip22zilog_init(void) static void __exit ip22zilog_exit(void) {int i; +struct uart_ip22zilog_port *up;for (i =0 ; i <NUM_CHANNELS ; i++) { -struct uart_ip22zilog_port *up = &ip22zilog_port_table[i]; + up = &ip22zilog_port_table[i];uart_remove_one_port (&ip22zilog_reg, &up->port); } +/* Free IO mem */ + up = &ip22zilog_port_table[0 ]; +for (i =0 ; i <NUM_IP22ZILOG ; i++) { +if (up[(i *2 ) +0 ].port.mapbase) { +iounmap ((void *)up[(i *2 ) +0 ].port.mapbase); + up[(i *2 ) +0 ].port.mapbase =0 ; + } +if (up[(i *2 ) +1 ].port.mapbase) { +iounmap ((void *)up[(i *2 ) +1 ].port.mapbase); + up[(i *2 ) +1 ].port.mapbase =0 ; + } + } +uart_unregister_driver (&ip22zilog_reg); }
drivers/serial/mpc52xx_uart.c +10 -1
@@ -338,14 +338,23 @@ mpc52xx_uart_release_port(struct uart_postatic int mpc52xx_uart_request_port (struct uart_port *port) { +int err; +if (port->flags &UPF_IOREMAP )/* Need to remap ? */ port->membase =ioremap (port->mapbase, MPC52xx_PSC_SIZE);if (!port->membase)return -EINVAL ; -return request_mem_region (port->mapbase, MPC52xx_PSC_SIZE, + err =request_mem_region (port->mapbase, MPC52xx_PSC_SIZE,"mpc52xx_psc_uart" ) !=NULL ?0 : -EBUSY ; + +if (err && (port->flags &UPF_IOREMAP )) { +iounmap (port->membase); + port->membase =NULL ; + } + +return err; } static void
drivers/serial/mpsc.c +12 -0
@@ -1893,6 +1893,10 @@ mpsc_drv_map_regs(struct mpsc_port_info }else {mpsc_resource_err ("SDMA base" ); +if (pi->mpsc_base) { +iounmap (pi->mpsc_base); + pi->mpsc_base =NULL ; + }return -ENOMEM ; }
@@ -1905,6 +1909,14 @@ mpsc_drv_map_regs(struct mpsc_port_info }else {mpsc_resource_err ("BRG base" ); +if (pi->mpsc_base) { +iounmap (pi->mpsc_base); + pi->mpsc_base =NULL ; + } +if (pi->sdma_base) { +iounmap (pi->sdma_base); + pi->sdma_base =NULL ; + }return -ENOMEM ; }
drivers/serial/mux.c +2 -0
@@ -521,6 +521,8 @@ static void __exit mux_exit(void)for (i =0 ; i < port_cnt; i++) {uart_remove_one_port (&mux_driver, &mux_ports[i]); +if (mux_ports[i].membase) +iounmap (mux_ports[i].membase); }uart_unregister_driver (&mux_driver);
drivers/serial/sunsu.c +3 -0
@@ -1499,6 +1499,9 @@ static int __devexit su_remove(struct ofuart_remove_one_port (&sunsu_reg, &up->port); } +if (up->port.membase) +of_iounmap (up->port.membase, up->reg_size); +dev_set_drvdata (&dev->dev,NULL );return 0 ;
Re: [KJ] [PATCH] ioremap balanced with iounmap for drivers/isdn
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
--- hisax/diva.c | 26 ++++++++++++++++++++++++-- hysdn/boardergo.c | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-)
---
drivers/isdn/hisax/diva.c +24 -2
@@ -716,8 +716,10 @@ release_io_diva(struct IsdnCardState *cs *cfg =0 ;/* disable INT0/1 */ *cfg =2 ;/* reset pending INT0 */ -iounmap ((void *)cs->hw.diva.cfg_reg); -iounmap ((void *)cs->hw.diva.pci_cfg); +if (cs->hw.diva.cfg_reg) +iounmap ((void *)cs->hw.diva.cfg_reg); +if (cs->hw.diva.pci_cfg) +iounmap ((void *)cs->hw.diva.pci_cfg);return ; }else if (cs->subtyp !=DIVA_IPAC_ISA ) {del_timer (&cs->hw.diva.tl);
@@ -734,6 +736,23 @@ release_io_diva(struct IsdnCardState *cs }static void +iounmap_diva (struct IsdnCardState *cs) +{ +if ((cs->subtyp =DIVA_IPAC_PCI ) || (cs->subtyp =DIVA_IPACX_PCI )) { +if (cs->hw.diva.cfg_reg) { +iounmap ((void *)cs->hw.diva.cfg_reg); + cs->hw.diva.cfg_reg =0 ; + } +if (cs->hw.diva.pci_cfg) { +iounmap ((void *)cs->hw.diva.pci_cfg); + cs->hw.diva.pci_cfg =0 ; + } + } + +return ; +} + +static void reset_diva (struct IsdnCardState *cs) {if (cs->subtyp =DIVA_IPAC_ISA ) {
@@ -1069,11 +1088,13 @@ setup_diva(struct IsdnCard *card)if (!cs->irq) {printk (KERN_WARNING "Diva: No IRQ for PCI card found\n" ); +iounmap_diva (cs);return (0 ); }if (!cs->hw.diva.cfg_reg) {printk (KERN_WARNING "Diva: No IO-Adr for PCI card found\n" ); +iounmap_diva (cs);return (0 ); } cs->irq_flags |=IRQF_SHARED ;
@@ -1123,6 +1144,7 @@ ready: CardType[card->typ], cs->hw.diva.cfg_reg, cs->hw.diva.cfg_reg + bytecnt); +iounmap_diva (cs);return (0 ); } }
drivers/isdn/hysdn/boardergo.c +1 -1
@@ -408,7 +408,7 @@ ergo_releasehardware(hysdn_card * card)free_irq (card->irq, card);/* release interrupt */ release_region (card->iobase +PCI9050_INTR_REG ,1 );/* release all io ports */ release_region (card->iobase +PCI9050_USER_IO ,1 ); -vfree (card->dpram); +iounmap (card->dpram); card->dpram =NULL ;/* release shared mem */ }/* ergo_releasehardware */
Signature · 7 lines
Karsten Keil SuSE Labs ISDN development _______________________________________________ Kernel-janitors mailing list [email protected] https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for drivers/parisc
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) to make sure the files are compiling without any warning/error due to new changes
--- dino.c | 4 +++- eisa.c | 1 + iosapic.c | 1 + lba_pci.c | 7 ++++++- 4 files changed, 11 insertions(+), 2 deletions(-)
---
drivers/parisc/dino.c +3 -1
@@ -1007,8 +1007,10 @@ static int __init dino_probe(struct paridino_bridge_init (dino_dev, name); } -if (dino_common_init (dev, dino_dev, name)) +if (dino_common_init (dev, dino_dev, name)) { +iounmap (dino_dev->hba.base_addr);return 1 ; + } dev->dev.platform_data = dino_dev;
drivers/parisc/eisa.c +1 -0
@@ -381,6 +381,7 @@ static int __devinit eisa_probe(struct p eisa_dev.root.dma_mask =0xffffffff ;/* wild guess */ if (eisa_root_register (&eisa_dev.root)) {printk (KERN_ERR "EISA: Failed to register EISA root\n" ); +iounmap (eisa_eeprom_addr);return -1 ; } }
drivers/parisc/iosapic.c +1 -0
@@ -887,6 +887,7 @@ void *iosapic_register(unsigned long hpa vip = isi->isi_vector = (struct vector_info *)kzalloc (sizeof (struct vector_info ) * isi->isi_num_vectors,GFP_KERNEL );if (vip =NULL ) { +iounmap (isi->addr);kfree (isi);return NULL ; }
drivers/parisc/lba_pci.c +6 -1
@@ -1574,6 +1574,7 @@ lba_driver_probe(struct parisc_device *d cfg_ops = &mercury_cfg_ops; }else {printk (KERN_ERR "Unknown LBA found at 0x%lx\n" , dev->hpa.start); +iounmap (addr);return -ENODEV ; }
@@ -1589,6 +1590,7 @@ lba_driver_probe(struct parisc_device *d lba_dev =kzalloc (sizeof (struct lba_device ),GFP_KERNEL );if (!lba_dev) {printk (KERN_ERR "lba_init_chip - couldn't alloc lba_device\n" ); +iounmap (addr);return (1 ); }
@@ -1606,8 +1608,11 @@ lba_driver_probe(struct parisc_device *dpcibios_register_hba (HBA_DATA (lba_dev));spin_lock_init (&lba_dev->lba_lock); -if (lba_hw_init (lba_dev)) +if (lba_hw_init (lba_dev)) { +iounmap (lba_dev->hba.base_addr); + lba_dev->hba.base_addr =NULL ;return (1 ); + }/* ---------- Third : setup I/O Port and MMIO resources --------- */
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for drivers/pci/hotplug
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
--- shpchp_hpc.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-)
---
drivers/pci/hotplug/shpchp_hpc.c +6 -1
@@ -1282,8 +1282,11 @@ int shpc_init(struct controller * ctrl,*/ if (atomic_add_return (1 , &shpchp_num_controllers) =1 ) { shpchp_wq =create_singlethread_workqueue ("shpchpd" ); -if (!shpchp_wq) +if (!shpchp_wq) { +iounmap (php_ctlr->creg); + php_ctlr->creg =NULL ;return -ENOMEM ; + } }/*
@@ -1313,6 +1316,8 @@ int shpc_init(struct controller * ctrl,/* We end up here for the many possible ways to fail this API. */ abort_free_ctlr: +if (php_ctlr->creg) +iounmap (php_ctlr->creg);kfree (php_ctlr); abort:DBG_LEAVE_ROUTINE
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for drivers/pcmcia
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) to make sure the files are compiling without any warning/error due to new changes
---
Please CC me. I'm not on linux-pcmcia
--- at91_cf.c | 3 ++- au1000_generic.c | 10 ++++++++++ m8xx_pcmcia.c | 12 ++++++++---- omap_cf.c | 3 ++- 4 files changed, 22 insertions(+), 6 deletions(-)
---
drivers/pcmcia/at91_cf.c +2 -1
@@ -316,9 +316,10 @@ static int __init at91_cf_probe(struct preturn 0 ; fail2: -iounmap ((void __iomem *) cf->socket.io_offset);release_mem_region (io->start, io->end +1 - io->start); fail1: +if (cf->socket.io_offset) +iounmap ((void __iomem *) cf->socket.io_offset);if (board->irq_pin)free_irq (board->irq_pin, cf); fail0a:
drivers/pcmcia/au1000_generic.c +10 -0
@@ -445,6 +445,16 @@ int au1x00_pcmcia_socket_probe(struct depcmcia_unregister_socket (&skt->socket); out_err:flush_scheduled_work (); +if (i =0 ) { +iounmap (skt->virt_io + (u32 )mips_io_port_base); + skt->virt_io =NULL ; + } +#ifndef CONFIG_MIPS_XXS1500 + else { +iounmap (skt->virt_io + (u32 )mips_io_port_base); + skt->virt_io =NULL ; + } +#endif ops->hw_shutdown (skt); i--;
drivers/pcmcia/m8xx_pcmcia.c +8 -4
@@ -427,7 +427,7 @@ static int voltage_set(int slot, int vcc reg |=BCSR1_PCCVCC1 ;break ;default : -return 1 ; + goto out_unmap; }switch (vpp) {
@@ -438,15 +438,15 @@ static int voltage_set(int slot, int vccif (vcc = vpp) reg |=BCSR1_PCCVPP1 ;else -return 1 ; + goto out_unmap;break ;case 120 :if ((vcc =33 ) || (vcc =50 )) reg |=BCSR1_PCCVPP0 ;else -return 1 ; + goto out_unmap;default : -return 1 ; + goto out_unmap; }/* first, turn off all power */
@@ -457,6 +457,10 @@ static int voltage_set(int slot, int vcciounmap (bcsr_io);return 0 ; + +out_unmap: +iounmap (bcsr_io); +return 1 ; }#define socket_get (_slot_) PCMCIA_SOCKET_KEY_5V
drivers/pcmcia/omap_cf.c +2 -1
@@ -306,9 +306,10 @@ static int __init omap_cf_probe(struct dreturn 0 ; fail2: -iounmap ((void __iomem *) cf->socket.io_offset);release_mem_region (cf->phys_cf,SZ_8K ); fail1: +if (cf->socket.io_offset) +iounmap ((void __iomem *) cf->socket.io_offset);free_irq (irq, cf); fail0:kfree (cf);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for drivers/video
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
- Modifying drivers/video/Kconfig to make sure that the changed file is compiling without error/warning
--- S3triofb.c | 7 +++++-- amifb.c | 8 +++++--- atafb.c | 13 ++++++++++++- aty/atyfb_base.c | 8 ++++++++ cirrusfb.c | 15 +++++++++++++-- console/newport_con.c | 9 ++++++++- cyberfb.c | 2 ++ ffb.c | 4 ++++ fm2fb.c | 1 + hpfb.c | 2 ++ macfb.c | 20 ++++++++++++++++++++ offb.c | 3 +++ platinumfb.c | 3 +++ pvr2fb.c | 18 ++++++++++++++++++ retz3fb.c | 4 +++- stifb.c | 3 +++ tgafb.c | 2 ++ tridentfb.c | 22 +++++++++++++++++----- vesafb.c | 2 ++ virgefb.c | 17 ++++++++++++++++- 20 files changed, 147 insertions(+), 16 deletions(-)
---
drivers/video/amifb.c +5 -3
@@ -2407,10 +2407,10 @@ default_chipset: fb_info.fix.smem_len);if (!videomemory) {printk ("amifb: WARNING! unable to map videomem cached writethrough\n" ); - videomemory =ZTWO_VADDR (fb_info.fix.smem_start); - } + fb_info.screen_base = (char *)ZTWO_VADDR (fb_info.fix.smem_start); + }else + fb_info.screen_base = (char *)videomemory; - fb_info.screen_base = (char *)videomemory;memset (dummysprite,0 ,DUMMYSPRITEMEMSIZE );/*
@@ -2453,6 +2453,8 @@ static void amifb_deinit(void) {fb_dealloc_cmap (&fb_info.cmap);chipfree (); +if (videomemory) +iounmap ((void *)videomemory);release_mem_region (CUSTOM_PHYSADDR +0xe0 ,0x120 ); custom.dmacon =DMAF_ALL |DMAF_MASTER ; }
drivers/video/atafb.c +12 -1
@@ -2804,8 +2804,19 @@ int __init atafb_init(void)atafb_set_disp (-1 , &fb_info);do_install_cmap (0 , &fb_info); -if (register_framebuffer (&fb_info) <0 ) +if (register_framebuffer (&fb_info) <0 ) { +#ifdef ATAFB_EXT +if (external_addr) { +iounmap (external_addr); + external_addr =NULL ; + } +if (external_vgaiobase) { +iounmap ((void *)external_vgaiobase); + external_vgaiobase =0 ; + } +#endif return -EINVAL ; + }printk ("Determined %dx%d, depth %d\n" , disp.var.xres, disp.var.yres, disp.var.bits_per_pixel);
drivers/video/aty/atyfb_base.c +8 -0
@@ -3530,6 +3530,10 @@ static int __devinit atyfb_setup_generic atyfb_setup_generic_fail:iounmap (par->ati_regbase); par->ati_regbase =NULL ; +if (info->screen_base) { +iounmap (info->screen_base); + info->screen_base =NULL ; + }return ret; }
@@ -3698,6 +3702,10 @@ static int __devinit atyfb_atari_probe(v }if (aty_init (info,"ISA bus" )) { +if (info->screen_base) +iounmap (info->screen_base); +if (par->ati_regbase) +iounmap (par->ati_regbase);framebuffer_release (info);/* This is insufficient! kernel_map has added two large chunks!! */ return -ENXIO ;
drivers/video/cirrusfb.c +13 -2
@@ -2442,7 +2442,10 @@ static int cirrusfb_pci_register (structprintk ("Cirrus Logic chipset on PCI bus\n" );pci_set_drvdata (pdev, info); -return cirrusfb_register (cinfo); + ret =cirrusfb_register (cinfo); +if (ret) +iounmap (cinfo->fbmem); +return ret; err_release_legacy:if (release_io_ports)
@@ -2574,7 +2577,15 @@ static int cirrusfb_zorro_register(strucprintk (KERN_INFO "Cirrus Logic chipset on Zorro bus\n" );zorro_set_drvdata (z, info); -return cirrusfb_register (cinfo); + ret =cirrusfb_register (cinfo); +if (ret) { +if (btype =BT_PICASSO4 ) { +iounmap (cinfo->fbmem); +iounmap (cinfo->regbase -0x600000 ); + }else if (board_addr >0x01000000 ) +iounmap (cinfo->fbmem); + } +return ret; err_unmap_regbase:/* Parental advisory: explicit hack */
drivers/video/console/newport_con.c +8 -1
@@ -323,6 +323,8 @@ static const char *newport_startup(void)return "SGI Newport" ; out_unmap: +iounmap ((void *)npregs); + npregs =NULL ;return NULL ; }
@@ -738,6 +740,7 @@ const struct consw newport_con = {#ifdef MODULE static int __init newport_console_init (void ) { +int err;if (!sgi_gfxaddr)return NULL ;
@@ -746,7 +749,11 @@ static int __init newport_console_init(v npregs = (struct newport_regs *)/* ioremap cannot fail */ ioremap (sgi_gfxaddr,sizeof (struct newport_regs )); -return take_over_console (&newport_con,0 ,MAX_NR_CONSOLES -1 ,1 ); + err =take_over_console (&newport_con,0 ,MAX_NR_CONSOLES -1 ,1 ); +if (err) +iounmap ((void *)npregs); + +return err; }module_init (newport_console_init);
drivers/video/cyberfb.c +2 -0
@@ -1055,6 +1055,8 @@ int __init cyberfb_init(void)if (register_framebuffer (&fb_info) <0 ) {DPRINTK ("EXIT - register_framebuffer failed\n" ); +if (CyberBase) +iounmap (CyberBase);release_mem_region (CyberMem_phys,0x400000 );release_mem_region (CyberRegs_phys,0x10000 );return -EINVAL ;
drivers/video/ffb.c +4 -0
@@ -968,6 +968,8 @@ static int ffb_init_one(struct of_deviceif (fb_alloc_cmap (&all->info.cmap,256 ,0 )) {printk (KERN_ERR "ffb: Could not allocate color map.\n" ); +of_iounmap (all->par.fbc,sizeof (struct ffb_fbc )); +of_iounmap (all->par.dac,sizeof (struct ffb_dac ));kfree (all);return -ENOMEM ; }
@@ -978,6 +980,8 @@ static int ffb_init_one(struct of_deviceif (err <0 ) {printk (KERN_ERR "ffb: Could not register framebuffer.\n" );fb_dealloc_cmap (&all->info.cmap); +of_iounmap (all->par.fbc,sizeof (struct ffb_fbc )); +of_iounmap (all->par.dac,sizeof (struct ffb_dac ));kfree (all);return err; }
drivers/video/fm2fb.c +1 -0
@@ -283,6 +283,7 @@ static int __devinit fm2fb_probe(structif (register_framebuffer (info) <0 ) {fb_dealloc_cmap (&info->cmap); +iounmap (info->screen_base);framebuffer_release (info);zorro_release_device (z);return -EINVAL ;
drivers/video/hpfb.c +2 -0
@@ -295,6 +295,8 @@ static int __init hpfb_init_one(unsignedif (register_framebuffer (&fb_info) <0 ) {fb_dealloc_cmap (&fb_info.cmap); +iounmap (fb_info.screen_base); + fb_info.screen_base =NULL ;return 1 ; }
drivers/video/macfb.c +20 -0
@@ -608,6 +608,22 @@ void __init macfb_setup(char *options) } } +static void __init iounmap_macfb (void ) +{ +if (valkyrie_cmap_regs) +iounmap (valkyrie_cmap_regs); +if (dafb_cmap_regs) +iounmap (dafb_cmap_regs); +if (v8_brazil_cmap_regs) +iounmap (v8_brazil_cmap_regs); +if (rbv_cmap_regs) +iounmap (rbv_cmap_regs); +if (civic_cmap_regs) +iounmap (civic_cmap_regs); +if (csc_cmap_regs) +iounmap (csc_cmap_regs); +} +static int __init macfb_init (void ) {int video_cmap_len, video_is_nubus =0 ;
@@ -962,6 +978,10 @@ static int __init macfb_init(void)if (!err)printk ("fb%d: %s frame buffer device\n" , fb_info.node, fb_info.fix.id); +else { +iounmap (fb_info.screen_base); +iounmap_macfb (); + }return err; }
drivers/video/offb.c +3 -0
@@ -392,6 +392,9 @@ static void __init offb_init_fb(const chfb_alloc_cmap (&info->cmap,256 ,0 );if (register_framebuffer (info) <0 ) { +iounmap (par->cmap_adr); + par->cmap_adr =NULL ; +iounmap (info->screen_base);kfree (info);release_mem_region (res_start, res_size);return ;
drivers/video/platinumfb.c +3 -0
@@ -623,6 +623,9 @@ static int __devinit platinumfb_probe(st rc =platinum_init_fb (info);if (rc !=0 ) { +iounmap (pinfo->frame_buffer); +iounmap (pinfo->platinum_regs); +iounmap (pinfo->cmap_regs);dev_set_drvdata (&odev->dev,NULL );framebuffer_release (info); }
drivers/video/pvr2fb.c +18 -0
@@ -903,6 +903,15 @@ static int __init pvr2fb_dc_init(void)static void pvr2fb_dc_exit (void ) { +if (fb_info->screen_base) { +iounmap (fb_info->screen_base); + fb_info->screen_base =NULL ; + } +if (currentpar->mmio_base) { +iounmap ((void *)currentpar->mmio_base); + currentpar->mmio_base =0 ; + } +free_irq (HW_EVENT_VSYNC ,0 );#ifdef CONFIG_SH_DMA free_dma (pvr2dma);
@@ -944,6 +953,15 @@ static int __devinit pvr2fb_pci_probe(st static void __devexit pvr2fb_pci_remove(struct pci_dev *pdev) { +if (fb_info->screen_base) { +iounmap (fb_info->screen_base); + fb_info->screen_base =NULL ; + } +if (currentpar->mmio_base) { +iounmap ((void *)currentpar->mmio_base); + currentpar->mmio_base =0 ; + } +pci_release_regions (pdev); }
drivers/video/retz3fb.c +3 -1
@@ -1423,8 +1423,10 @@ int __init retz3fb_init(void)do_install_cmap (0 , fb_info); -if (register_framebuffer (fb_info) <0 ) +if (register_framebuffer (fb_info) <0 ) { +iounmap (zinfo->base);return -EINVAL ; + } printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of " "video memory\n", fb_info->node,
drivers/video/S3triofb.c +5 -2
@@ -535,8 +535,11 @@ static void __init s3triofb_of_init(stru#endif fb_info.flags =FBINFO_FLAG_DEFAULT ; -if (register_framebuffer (&fb_info) <0 ) -return ; +if (register_framebuffer (&fb_info) <0 ) { +iounmap (fb_info.screen_base); + fb_info.screen_base =NULL ; +return ; + }printk ("fb%d: S3 Trio frame buffer device on %s\n" , fb_info.node, dp->full_name);
drivers/video/stifb.c +3 -0
@@ -1291,6 +1291,7 @@ out_err3: out_err2:release_mem_region (fix->smem_start, fix->smem_len); out_err1: +iounmap (info->screen_base);fb_dealloc_cmap (&info->cmap); out_err0:kfree (fb);
@@ -1364,6 +1365,8 @@ stifb_cleanup(void)unregister_framebuffer (sti->info);release_mem_region (info->fix.mmio_start, info->fix.mmio_len);release_mem_region (info->fix.smem_start, info->fix.smem_len); +if (info->screen_base) +iounmap (info->screen_base);fb_dealloc_cmap (&info->cmap);kfree (info); }
drivers/video/tgafb.c +2 -0
@@ -1473,6 +1473,8 @@ tgafb_pci_register(struct pci_dev *pdev,return 0 ; err1: +if (mem_base) +iounmap (mem_base);release_mem_region (bar0_start, bar0_len); err0:kfree (all);
drivers/video/tridentfb.c +17 -5
@@ -1130,7 +1130,8 @@ static int __devinit trident_pci_probe(sif (!request_mem_region (tridentfb_fix.smem_start, tridentfb_fix.smem_len,"tridentfb" )) {debug ("request_mem_region failed!\n" ); -return -1 ; + err =-1 ; + goto out_unmap; } fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start,
@@ -1139,7 +1140,8 @@ static int __devinit trident_pci_probe(sif (!fb_info.screen_base) {release_mem_region (tridentfb_fix.smem_start, tridentfb_fix.smem_len);debug ("ioremap failed\n" ); -return -1 ; + err =-1 ; + goto out_unmap; }output ("%s board found\n" ,pci_name (dev));
@@ -1162,8 +1164,10 @@ static int __devinit trident_pci_probe(s#endif fb_info.pseudo_palette = pseudo_pal; -if (!fb_find_mode (&default_var,&fb_info,mode,NULL ,0 ,NULL ,bpp)) -return -EINVAL ; +if (!fb_find_mode (&default_var,&fb_info,mode,NULL ,0 ,NULL ,bpp)) { + err = -EINVAL ; + goto out_unmap; + }fb_alloc_cmap (&fb_info.cmap,256 ,0 );if (defaultaccel && acc) default_var.accel_flags |=FB_ACCELF_TEXT ;
@@ -1174,12 +1178,20 @@ static int __devinit trident_pci_probe(s fb_info.device = &dev->dev;if (register_framebuffer (&fb_info) <0 ) {printk (KERN_ERR "tridentfb: could not register Trident framebuffer\n" ); -return -EINVAL ; + err = -EINVAL ; + goto out_unmap; }output ("fb%d: %s frame buffer device %dx%d-%dbpp\n" , fb_info.node, fb_info.fix.id,default_var.xres, default_var.yres,default_var.bits_per_pixel);return 0 ; + +out_unmap: +if (default_par.io_virt) +iounmap (default_par.io_virt); +if (fb_info.screen_base) +iounmap (fb_info.screen_base); +return err; } static void __devexit trident_pci_remove(struct pci_dev * dev)
drivers/video/vesafb.c +2 -0
@@ -456,6 +456,8 @@ static int __init vesafb_probe(struct pl info->node, info->fix.id);return 0 ; err: +if (info->screen_base) +iounmap (info->screen_base);framebuffer_release (info);release_mem_region (vesafb_fix.smem_start, size_total);return err;
drivers/video/virgefb.c +16 -1
@@ -1799,7 +1799,7 @@ int __init virgefb_init(void)#warning release resourcesprintk (KERN_ERR "virgefb.c: register_framebuffer failed\n" );DPRINTK ("EXIT\n" ); -return -EINVAL ; + goto out_unmap; } printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of video memory\n",
@@ -1809,6 +1809,21 @@ int __init virgefb_init(void)DPRINTK ("EXIT\n" );return 0 ; + +out_unmap: +if (board_addr >=0x01000000 ) { +if (v_ram) +iounmap ((void *)v_ram); +if (vgaio_regs) +iounmap (vgaio_regs); +if (mmio_regs) +iounmap (mmio_regs); +if (vcode_switch_base) +iounmap ((void *)vcode_switch_base); + v_ram = vcode_switch_base =0 ; + vgaio_regs = mmio_regs =NULL ; + } +return -EINVAL ; }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH] ioremap balanced with iounmap for drivers/video
In reply to Amol LadAmol,
We are not responsible for video adapter drivers, but, instead, for video capture adapters. I suggest you to send your patch to LKML, where all kernel maintainers are ([email protected]).
Cheers,
Mauro.
Em Sex, 2006-09-29 às 18:30 +0530, Amol Lad escreveu:
Quoted 485 lines
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) with:
- allmodconfig
- Modifyingdrivers/video/Kconfigto make sure that the changed file is compiling without error/warningSigned-off-by Amol Lad <[email protected]>--- S3triofb.c | 7 +++++-- amifb.c | 8 +++++--- atafb.c | 13 ++++++++++++- aty/atyfb_base.c | 8 ++++++++ cirrusfb.c | 15 +++++++++++++-- console/newport_con.c | 9 ++++++++- cyberfb.c | 2 ++ ffb.c | 4 ++++ fm2fb.c | 1 + hpfb.c | 2 ++ macfb.c | 20 ++++++++++++++++++++ offb.c | 3 +++ platinumfb.c | 3 +++ pvr2fb.c | 18 ++++++++++++++++++ retz3fb.c | 4 +++- stifb.c | 3 +++ tgafb.c | 2 ++ tridentfb.c | 22 +++++++++++++++++----- vesafb.c | 2 ++ virgefb.c | 17 ++++++++++++++++- 20 files changed, 147 insertions(+), 16 deletions(-)---
diff -uprN -X linux-2.6.18-orig/Documentation/dontdifflinux-2.6.18-orig/drivers/video/amifb.clinux-2.6.18/drivers/video/amifb.cdrivers/video/amifb.c +5
-3@@ -2407,10 +2407,10 @@ default_chipset: fb_info.fix.smem_len);if (!videomemory) {printk ("amifb: WARNING! unable to map videomem cached writethrough\n" ); - videomemory =ZTWO_VADDR (fb_info.fix.smem_start); - } + fb_info.screen_base = (char *)ZTWO_VADDR (fb_info.fix.smem_start); + }else + fb_info.screen_base = (char *)videomemory; - fb_info.screen_base = (char *)videomemory;memset (dummysprite,0 ,DUMMYSPRITEMEMSIZE );/* @@ -2453,6 +2453,8 @@ static void amifb_deinit(void) {fb_dealloc_cmap (&fb_info.cmap);chipfree (); +if (videomemory) +iounmap ((void *)videomemory);release_mem_region (CUSTOM_PHYSADDR +0xe0 ,0x120 ); custom.dmacon =DMAF_ALL |DMAF_MASTER ; }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/atafb.clinux-2.6.18/drivers/video/atafb.cdrivers/video/atafb.c +12
-1@@ -2804,8 +2804,19 @@ int __init atafb_init(void)atafb_set_disp (-1 , &fb_info);do_install_cmap (0 , &fb_info); -if (register_framebuffer (&fb_info) <0 ) +if (register_framebuffer (&fb_info) <0 ) { +#ifdef ATAFB_EXT +if (external_addr) { +iounmap (external_addr); + external_addr =NULL ; + } +if (external_vgaiobase) { +iounmap ((void *)external_vgaiobase); + external_vgaiobase =0 ; + } +#endif return -EINVAL ; + }printk ("Determined %dx%d, depth %d\n" , disp.var.xres, disp.var.yres, disp.var.bits_per_pixel);diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/aty/atyfb_base.clinux-2.6.18/drivers/video/aty/atyfb_base.cdrivers/video/aty/atyfb_base.c +8
-0@@ -3530,6 +3530,10 @@ static int __devinit atyfb_setup_generic atyfb_setup_generic_fail:iounmap (par->ati_regbase); par->ati_regbase =NULL ; +if (info->screen_base) { +iounmap (info->screen_base); + info->screen_base =NULL ; + }return ret; }@@ -3698,6 +3702,10 @@ static int __devinit atyfb_atari_probe(v }if (aty_init (info,"ISA bus" )) { +if (info->screen_base) +iounmap (info->screen_base); +if (par->ati_regbase) +iounmap (par->ati_regbase);framebuffer_release (info);/* This is insufficient! kernel_map has added two large chunks!! */ return -ENXIO ;diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/cirrusfb.clinux-2.6.18/drivers/video/cirrusfb.cdrivers/video/cirrusfb.c +13
-2@@ -2442,7 +2442,10 @@ static int cirrusfb_pci_register (structprintk ("Cirrus Logic chipset on PCI bus\n" );pci_set_drvdata (pdev, info); -return cirrusfb_register (cinfo); + ret =cirrusfb_register (cinfo); +if (ret) +iounmap (cinfo->fbmem); +return ret; err_release_legacy:if (release_io_ports)@@ -2574,7 +2577,15 @@ static int cirrusfb_zorro_register(strucprintk (KERN_INFO "Cirrus Logic chipset on Zorro bus\n" );zorro_set_drvdata (z, info); -return cirrusfb_register (cinfo); + ret =cirrusfb_register (cinfo); +if (ret) { +if (btype =BT_PICASSO4 ) { +iounmap (cinfo->fbmem); +iounmap (cinfo->regbase -0x600000 ); + }else if (board_addr >0x01000000 ) +iounmap (cinfo->fbmem); + } +return ret; err_unmap_regbase:/* Parental advisory: explicit hack */ diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/console/newport_con.clinux-2.6.18/drivers/video/console/newport_con.cdrivers/video/console/newport_con.c +8
-1@@ -323,6 +323,8 @@ static const char *newport_startup(void)return "SGI Newport" ; out_unmap: +iounmap ((void *)npregs); + npregs =NULL ;return NULL ; }@@ -738,6 +740,7 @@ const struct consw newport_con = {#ifdef MODULE static int __init newport_console_init (void ) { +int err;if (!sgi_gfxaddr)return NULL ;@@ -746,7 +749,11 @@ static int __init newport_console_init(v npregs = (struct newport_regs *)/* ioremap cannot fail */ ioremap (sgi_gfxaddr,sizeof (struct newport_regs )); -return take_over_console (&newport_con,0 ,MAX_NR_CONSOLES -1 ,1 ); + err =take_over_console (&newport_con,0 ,MAX_NR_CONSOLES -1 ,1 ); +if (err) +iounmap ((void *)npregs); + +return err; }module_init (newport_console_init);diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/cyberfb.clinux-2.6.18/drivers/video/cyberfb.cdrivers/video/cyberfb.c +2
-0@@ -1055,6 +1055,8 @@ int __init cyberfb_init(void)if (register_framebuffer (&fb_info) <0 ) {DPRINTK ("EXIT - register_framebuffer failed\n" ); +if (CyberBase) +iounmap (CyberBase);release_mem_region (CyberMem_phys,0x400000 );release_mem_region (CyberRegs_phys,0x10000 );return -EINVAL ;diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/ffb.clinux-2.6.18/drivers/video/ffb.cdrivers/video/ffb.c +4
-0@@ -968,6 +968,8 @@ static int ffb_init_one(struct of_deviceif (fb_alloc_cmap (&all->info.cmap,256 ,0 )) {printk (KERN_ERR "ffb: Could not allocate color map.\n" ); +of_iounmap (all->par.fbc,sizeof (struct ffb_fbc )); +of_iounmap (all->par.dac,sizeof (struct ffb_dac ));kfree (all);return -ENOMEM ; }@@ -978,6 +980,8 @@ static int ffb_init_one(struct of_deviceif (err <0 ) {printk (KERN_ERR "ffb: Could not register framebuffer.\n" );fb_dealloc_cmap (&all->info.cmap); +of_iounmap (all->par.fbc,sizeof (struct ffb_fbc )); +of_iounmap (all->par.dac,sizeof (struct ffb_dac ));kfree (all);return err; }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/fm2fb.clinux-2.6.18/drivers/video/fm2fb.cdrivers/video/fm2fb.c +1
-0@@ -283,6 +283,7 @@ static int __devinit fm2fb_probe(structif (register_framebuffer (info) <0 ) {fb_dealloc_cmap (&info->cmap); +iounmap (info->screen_base);framebuffer_release (info);zorro_release_device (z);return -EINVAL ;diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/hpfb.clinux-2.6.18/drivers/video/hpfb.cdrivers/video/hpfb.c +2
-0@@ -295,6 +295,8 @@ static int __init hpfb_init_one(unsignedif (register_framebuffer (&fb_info) <0 ) {fb_dealloc_cmap (&fb_info.cmap); +iounmap (fb_info.screen_base); + fb_info.screen_base =NULL ;return 1 ; }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/macfb.clinux-2.6.18/drivers/video/macfb.cdrivers/video/macfb.c +20
-0@@ -608,6 +608,22 @@ void __init macfb_setup(char *options) } } +static void __init iounmap_macfb (void ) +{ +if (valkyrie_cmap_regs) +iounmap (valkyrie_cmap_regs); +if (dafb_cmap_regs) +iounmap (dafb_cmap_regs); +if (v8_brazil_cmap_regs) +iounmap (v8_brazil_cmap_regs); +if (rbv_cmap_regs) +iounmap (rbv_cmap_regs); +if (civic_cmap_regs) +iounmap (civic_cmap_regs); +if (csc_cmap_regs) +iounmap (csc_cmap_regs); +} +static int __init macfb_init (void ) {int video_cmap_len, video_is_nubus =0 ;@@ -962,6 +978,10 @@ static int __init macfb_init(void)if (!err)printk ("fb%d: %s frame buffer device\n" , fb_info.node, fb_info.fix.id); +else { +iounmap (fb_info.screen_base); +iounmap_macfb (); + }return err; }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/offb.clinux-2.6.18/drivers/video/offb.cdrivers/video/offb.c +3
-0@@ -392,6 +392,9 @@ static void __init offb_init_fb(const chfb_alloc_cmap (&info->cmap,256 ,0 );if (register_framebuffer (info) <0 ) { +iounmap (par->cmap_adr); + par->cmap_adr =NULL ; +iounmap (info->screen_base);kfree (info);release_mem_region (res_start, res_size);return ;diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/platinumfb.clinux-2.6.18/drivers/video/platinumfb.cdrivers/video/platinumfb.c +3
-0@@ -623,6 +623,9 @@ static int __devinit platinumfb_probe(st rc =platinum_init_fb (info);if (rc !=0 ) { +iounmap (pinfo->frame_buffer); +iounmap (pinfo->platinum_regs); +iounmap (pinfo->cmap_regs);dev_set_drvdata (&odev->dev,NULL );framebuffer_release (info); }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/pvr2fb.clinux-2.6.18/drivers/video/pvr2fb.cdrivers/video/pvr2fb.c +18
-0@@ -903,6 +903,15 @@ static int __init pvr2fb_dc_init(void)static void pvr2fb_dc_exit (void ) { +if (fb_info->screen_base) { +iounmap (fb_info->screen_base); + fb_info->screen_base =NULL ; + } +if (currentpar->mmio_base) { +iounmap ((void *)currentpar->mmio_base); + currentpar->mmio_base =0 ; + } +free_irq (HW_EVENT_VSYNC ,0 );#ifdef CONFIG_SH_DMA free_dma (pvr2dma);@@ -944,6 +953,15 @@ static int __devinit pvr2fb_pci_probe(st static void __devexit pvr2fb_pci_remove(struct pci_dev *pdev) { +if (fb_info->screen_base) { +iounmap (fb_info->screen_base); + fb_info->screen_base =NULL ; + } +if (currentpar->mmio_base) { +iounmap ((void *)currentpar->mmio_base); + currentpar->mmio_base =0 ; + } +pci_release_regions (pdev); }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/retz3fb.clinux-2.6.18/drivers/video/retz3fb.cdrivers/video/retz3fb.c +3
-1@@ -1423,8 +1423,10 @@ int __init retz3fb_init(void)do_install_cmap (0 , fb_info); -if (register_framebuffer (fb_info) <0 ) +if (register_framebuffer (fb_info) <0 ) { +iounmap (zinfo->base);return -EINVAL ; + } printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of " "video memory\n", fb_info->node,diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/S3triofb.clinux-2.6.18/drivers/video/S3triofb.cdrivers/video/S3triofb.c +5
-2@@ -535,8 +535,11 @@ static void __init s3triofb_of_init(stru#endif fb_info.flags =FBINFO_FLAG_DEFAULT ; -if (register_framebuffer (&fb_info) <0 ) -return ; +if (register_framebuffer (&fb_info) <0 ) { +iounmap (fb_info.screen_base); + fb_info.screen_base =NULL ; +return ; + }printk ("fb%d: S3 Trio frame buffer device on %s\n" , fb_info.node, dp->full_name);diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/stifb.clinux-2.6.18/drivers/video/stifb.cdrivers/video/stifb.c +3
-0@@ -1291,6 +1291,7 @@ out_err3: out_err2:release_mem_region (fix->smem_start, fix->smem_len); out_err1: +iounmap (info->screen_base);fb_dealloc_cmap (&info->cmap); out_err0:kfree (fb);@@ -1364,6 +1365,8 @@ stifb_cleanup(void)unregister_framebuffer (sti->info);release_mem_region (info->fix.mmio_start, info->fix.mmio_len);release_mem_region (info->fix.smem_start, info->fix.smem_len); +if (info->screen_base) +iounmap (info->screen_base);fb_dealloc_cmap (&info->cmap);kfree (info); }diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/tgafb.clinux-2.6.18/drivers/video/tgafb.cdrivers/video/tgafb.c +2
-0@@ -1473,6 +1473,8 @@ tgafb_pci_register(struct pci_dev *pdev,return 0 ; err1: +if (mem_base) +iounmap (mem_base);release_mem_region (bar0_start, bar0_len); err0:kfree (all);diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/tridentfb.clinux-2.6.18/drivers/video/tridentfb.cdrivers/video/tridentfb.c +17
-5@@ -1130,7 +1130,8 @@ static int __devinit trident_pci_probe(sif (!request_mem_region (tridentfb_fix.smem_start, tridentfb_fix.smem_len,"tridentfb" )) {debug ("request_mem_region failed!\n" ); -return -1 ; + err =-1 ; + goto out_unmap; } fb_info.screen_base = ioremap_nocache(tridentfb_fix.smem_start,@@ -1139,7 +1140,8 @@ static int __devinit trident_pci_probe(sif (!fb_info.screen_base) {release_mem_region (tridentfb_fix.smem_start, tridentfb_fix.smem_len);debug ("ioremap failed\n" ); -return -1 ; + err =-1 ; + goto out_unmap; }output ("%s board found\n" ,pci_name (dev));@@ -1162,8 +1164,10 @@ static int __devinit trident_pci_probe(s#endif fb_info.pseudo_palette = pseudo_pal; -if (!fb_find_mode (&default_var,&fb_info,mode,NULL ,0 ,NULL ,bpp)) -return -EINVAL ; +if (!fb_find_mode (&default_var,&fb_info,mode,NULL ,0 ,NULL ,bpp)) { + err = -EINVAL ; + goto out_unmap; + }fb_alloc_cmap (&fb_info.cmap,256 ,0 );if (defaultaccel && acc) default_var.accel_flags |=FB_ACCELF_TEXT ;@@ -1174,12 +1178,20 @@ static int __devinit trident_pci_probe(s fb_info.device = &dev->dev;if (register_framebuffer (&fb_info) <0 ) {printk (KERN_ERR "tridentfb: could not register Trident framebuffer\n" ); -return -EINVAL ; + err = -EINVAL ; + goto out_unmap; }output ("fb%d: %s frame buffer device %dx%d-%dbpp\n" , fb_info.node, fb_info.fix.id,default_var.xres, default_var.yres,default_var.bits_per_pixel);return 0 ; + +out_unmap: +if (default_par.io_virt) +iounmap (default_par.io_virt); +if (fb_info.screen_base) +iounmap (fb_info.screen_base); +return err; } static void __devexit trident_pci_remove(struct pci_dev * dev)diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/vesafb.clinux-2.6.18/drivers/video/vesafb.cdrivers/video/vesafb.c +2
-0@@ -456,6 +456,8 @@ static int __init vesafb_probe(struct pl info->node, info->fix.id);return 0 ; err: +if (info->screen_base) +iounmap (info->screen_base);framebuffer_release (info);release_mem_region (vesafb_fix.smem_start, size_total);return err;diff -uprN -X linux-2.6.18-orig/Documentation/dontdiff
linux-2.6.18-orig/drivers/video/virgefb.clinux-2.6.18/drivers/video/virgefb.cdrivers/video/virgefb.c +9
-1@@ -1799,7 +1799,7 @@ int __init virgefb_init(void)#warning release resourcesprintk (KERN_ERR "virgefb.c: register_framebuffer failed\n" );DPRINTK ("EXIT\n" ); -return -EINVAL ; + goto out_unmap; } printk(KERN_INFO "fb%d: %s frame buffer device, using %ldK of video memory\n",@@ -1809,6 +1809,21 @@ int __init virgefb_init(void)DPRINTK ("EXIT\n" );return 0 ; + +out_unmap: +if (board_addr >=0x01000000 ) { +if (v_ram) +iounmap ((void *)v_ram); +if (vgaio_regs) +iounmap (vgaio_regs); +if (mmio_regs)
drivers/video/virgefb.c int __init virgefb_init(void) · line 1829
Quoted 10 lines
drivers/video/virgefb.c +7
-0+iounmap (mmio_regs); +if (vcode_switch_base) +iounmap ((void *)vcode_switch_base); + v_ram = vcode_switch_base =0 ; + vgaio_regs = mmio_regs =NULL ; + } +return -EINVAL ; }
Cheers,
Mauro.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [PATCH] ioremap balanced with iounmap for drivers/video
In reply to Amol LadQuoted 5 lines · On Fri, 29 Sep 2006 11:43:28 -0300 Mauro Carvalho Chehab wrote:
Amol,
We are not responsible for video adapter drivers, but, instead, for video capture adapters. I suggest you to send your patch to LKML, where all kernel maintainers are ([email protected]).
SCSI maintainer doesn't follow lkml. There could be others as well. network drivers definitely should go to netdev mailing list. video adapter drivers could also go to linux-fbdev mailing list...
lkml is not the answer for everything IHHO.
However, if Andrew Morton picks up the patch, he will likely test it in -mm for awhile and then forward it to the correct people so that they can merge it.
---
~Randy
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for drivers/atm
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only) to make sure the files are compiling without any warning/error due to new changes
--- eni.c | 13 +++++++++++-- firestream.c | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-)
---
drivers/atm/eni.c +11 -2
@@ -1746,6 +1746,7 @@ static int __devinit eni_do_init(struct printk(KERN_ERR KERN_ERR DEV_LABEL "(itf %d): bad ""magic - expected 0x%x, got 0x%x\n" ,dev->number, ENI155_MAGIC,(unsigned) readl(&eprom->magic)); +iounmap (base);return -EINVAL ; } }
@@ -1773,17 +1774,25 @@ static int __devinit eni_do_init(structprintk (")\n" ); printk(KERN_ERR DEV_LABEL "(itf %d): ERROR - wrong id 0x%x\n", dev->number,(unsigned) eni_in(MID_RES_ID_MCON)); +iounmap (base);return -EINVAL ; } error = eni_dev->asic ?get_esi_asic (dev) :get_esi_fpga (dev,base); -if (error)return error; +if (error) { +iounmap (base); +return error; + }for (i =0 ; i <ESI_LEN ; i++)printk ("%s%02X" ,i ?"-" :"" ,dev->esi[i]);printk (")\n" ); printk(KERN_NOTICE DEV_LABEL "(itf %d): %s,%s\n",dev->number,eni_in (MID_RES_ID_MCON ) &0x200 ?"ASIC" :"FPGA" , media_name[eni_in(MID_RES_ID_MCON) & DAUGTHER_ID]); -return suni_init (dev); + + error =suni_init (dev); +if (error) +iounmap (base); +return error; }
drivers/atm/firestream.c +6 -0
@@ -1699,6 +1699,7 @@ static int __devinit fs_init (struct fs_/* This bit is documented as "RESERVED" */ if (isr &ISR_INIT_ERR ) {printk (KERN_ERR "Error initializing the FS... \n" ); +iounmap (dev->base);return 1 ; }if (isr &ISR_INIT ) {
@@ -1712,6 +1713,7 @@ static int __devinit fs_init (struct fs_if (!to) {printk (KERN_ERR "timeout initializing the FS... \n" ); +iounmap (dev->base);return 1 ; }
@@ -1792,6 +1794,7 @@ static int __devinit fs_init (struct fs_if (!dev->atm_vccs) {printk (KERN_WARNING "Couldn't allocate memory for VCC buffers. Woops!\n" );/* XXX Clean up..... */ +iounmap (dev->base);return 1 ; }memset (dev->atm_vccs,0 , dev->nchannels *sizeof (struct atm_vcc *));
@@ -1803,6 +1806,7 @@ static int __devinit fs_init (struct fs_if (!dev->tx_inuse) {printk (KERN_WARNING "Couldn't allocate memory for tx_inuse bits!\n" );/* XXX Clean up..... */ +iounmap (dev->base);return 1 ; }memset (dev->tx_inuse,0 , dev->nchannels /8 );
@@ -1832,6 +1836,7 @@ static int __devinit fs_init (struct fs_if (request_irq (dev->irq, fs_irq,IRQF_SHARED ,"firestream" , dev)) {printk (KERN_WARNING "couldn't get irq %d for firestream.\n" , pci_dev->irq);/* XXX undo all previous stuff... */ +iounmap (dev->base);return 1 ; }fs_dprintk (FS_DEBUG_INIT ,"Grabbed irq %d for dev at %p.\n" , dev->irq, dev);
@@ -2007,6 +2012,7 @@ static void __devexit firestream_remove_for (i=0 ;i <FS_NR_RX_QUEUES ;i++)free_queue (dev, &dev->rx_rq[i]); +iounmap (dev->base);fs_dprintk (FS_DEBUG_ALLOC ,"Free fs-dev: %p\n" , dev); nxtdev = dev->next;kfree (dev);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
PATCH 1/1 ioremap balanced with iounmap for sound
In reply to Amol Ladioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Tested (compilation only):
- using allmodconfig
- making sure the files are compiling without any warning/error due to new changes
--- oss/btaudio.c | 2 ++ oss/dmasound/dmasound_awacs.c | 39 +++++++++++++++++++++++++++++++++++---- oss/msnd_pinnacle.c | 10 ++++++++++ pci/au88x0/au88x0.c | 1 + pci/rme32.c | 4 ++++ pci/rme96.c | 4 ++++ pci/rme9652/hdsp.c | 21 ++++++++++++++++----- pci/rme9652/hdspm.c | 6 +++++- pci/rme9652/rme9652.c | 4 ++++ 9 files changed, 81 insertions(+), 10 deletions(-)
---
sound/oss/btaudio.c +2 -0
@@ -1013,6 +1013,7 @@ static int __devinit btaudio_probe(strucreturn 0 ; fail4: +iounmap (bta->mmio);unregister_sound_dsp (bta->dsp_analog); fail3:if (digital)
@@ -1051,6 +1052,7 @@ static void __devexit btaudio_remove(strfree_irq (bta->irq,bta);release_mem_region (pci_resource_start (pci_dev,0 ),pci_resource_len (pci_dev,0 )); +iounmap (bta->mmio);/* remove from linked list */ if (bta = btaudios) {
sound/oss/dmasound/dmasound_awacs.c +35 -4
@@ -3067,8 +3067,9 @@ printk("dmasound_pmac: Awacs/Screamer Coudelay (1 );/* Initialize beep stuff */ -if ((res=setup_beep ())) -return res ; + res=setup_beep (); +if (res) + goto out_unmap;#ifdef CONFIG_PM pmu_register_sleep_notifier (&awacs_sleep_notifier);
@@ -3160,7 +3161,26 @@ printk("dmasound_pmac: Awacs/Screamer Co*/ input_register_device (awacs_beep_dev); -return dmasound_init (); + res =dmasound_init (); +if (res) + goto out_unmap1; + +return 0 ; + +out_unmap1: +if (is_pbook_3X00) +iounmap (latch_base); +else if (is_pbook_g3) +iounmap (macio_base); +out_unmap: +if (i2s_node) +iounmap (i2s); +else +iounmap (awacs); +iounmap (awacs_txdma); +iounmap (awacs_rxdma); + +return res; } static void __exit dmasound_awacs_cleanup(void)
@@ -3177,8 +3197,19 @@ static void __exit dmasound_awacs_cleanudaca_cleanup ();break ; } -dmasound_deinit (); +if (is_pbook_3X00) +iounmap (latch_base); +else if (is_pbook_g3) +iounmap (macio_base); +if (i2s_node) +iounmap (i2s); +else +iounmap (awacs); +iounmap (awacs_txdma); +iounmap (awacs_rxdma); + +dmasound_deinit (); }MODULE_DESCRIPTION ("PowerMac built-in audio driver." );
sound/oss/msnd_pinnacle.c +10 -0
@@ -1441,6 +1441,8 @@ static int __init attach_multisound(void static void __exit unload_multisound(void) { +iounmap (dev.base); + dev.base =NULL ;release_region (dev.io, dev.numio);free_irq (dev.irq, &dev);unregister_sound_mixer (dev.mixer_minor);
@@ -1884,12 +1886,16 @@ static int __init msnd_init(void) printk(KERN_INFO LOGNAME ": %u byte audio FIFOs (x2)\n", dev.fifosize);if ((err =msnd_fifo_alloc (&dev.DAPF, dev.fifosize)) <0 ) { printk(KERN_ERR LOGNAME ": Couldn't allocate write FIFO\n"); +iounmap (dev.base); + dev.base =NULL ;return err; }if ((err =msnd_fifo_alloc (&dev.DARF, dev.fifosize)) <0 ) { printk(KERN_ERR LOGNAME ": Couldn't allocate read FIFO\n");msnd_fifo_free (&dev.DAPF); +iounmap (dev.base); + dev.base =NULL ;return err; }
@@ -1897,6 +1903,8 @@ static int __init msnd_init(void) printk(KERN_ERR LOGNAME ": Probe failed\n");msnd_fifo_free (&dev.DAPF);msnd_fifo_free (&dev.DARF); +iounmap (dev.base); + dev.base =NULL ;return err; }
@@ -1904,6 +1912,8 @@ static int __init msnd_init(void) printk(KERN_ERR LOGNAME ": Attach failed\n");msnd_fifo_free (&dev.DAPF);msnd_fifo_free (&dev.DARF); +iounmap (dev.base); + dev.base =NULL ;return err; }
sound/pci/au88x0/au88x0.c +1 -0
@@ -128,6 +128,7 @@ static int snd_vortex_dev_free(struct sn// Take down PCI interface. synchronize_irq (vortex->irq);free_irq (vortex->irq, vortex); +iounmap (vortex->mmio);pci_release_regions (vortex->pci_dev);pci_disable_device (vortex->pci_dev);kfree (vortex);
sound/pci/rme32.c +4 -0
@@ -1376,6 +1376,7 @@ static int __devinit snd_rme32_create(stif (request_irq (pci->irq, snd_rme32_interrupt,IRQF_DISABLED |IRQF_SHARED ,"RME32" , (void *) rme32)) {snd_printk (KERN_ERR "unable to grab IRQ %d\n" , pci->irq); +iounmap (rme32->iobase);return -EBUSY ; } rme32->irq = pci->irq;
@@ -1385,6 +1386,7 @@ static int __devinit snd_rme32_create(st/* set up ALSA pcm device for S/PDIF */ if ((err =snd_pcm_new (rme32->card,"Digi32 IEC958" ,0 ,1 ,1 , &rme32->spdif_pcm)) <0 ) { +iounmap (rme32->iobase);return err; } rme32->spdif_pcm->private_data = rme32;
@@ -1417,6 +1419,7 @@ static int __devinit snd_rme32_create(stif ((err =snd_pcm_new (rme32->card,"Digi32 ADAT" ,1 ,1 ,1 , &rme32->adat_pcm)) <0 ) { +iounmap (rme32->iobase);return err; } rme32->adat_pcm->private_data = rme32;
@@ -1462,6 +1465,7 @@ static int __devinit snd_rme32_create(st/* init switch interface */ if ((err =snd_rme32_create_switches (rme32->card, rme32)) <0 ) { +iounmap (rme32->iobase);return err; }
sound/pci/rme9652/hdsp.c +16 -5
@@ -4936,6 +4936,7 @@ static int __devinit snd_hdsp_create(strif (request_irq (pci->irq, snd_hdsp_interrupt,IRQF_DISABLED |IRQF_SHARED ,"hdsp" , (void *)hdsp)) {snd_printk (KERN_ERR "Hammerfall-DSP: unable to use IRQ %d\n" , pci->irq); +iounmap (hdsp->iobase);return -EBUSY ; }
@@ -4943,8 +4944,10 @@ static int __devinit snd_hdsp_create(str hdsp->precise_ptr =1 ; hdsp->use_midi_tasklet =1 ; -if ((err =snd_hdsp_initialize_memory (hdsp)) <0 ) +if ((err =snd_hdsp_initialize_memory (hdsp)) <0 ) { +iounmap (hdsp->iobase);return err; + }if (!is_9652 && !is_9632) {/* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */
@@ -4964,8 +4967,10 @@ static int __devinit snd_hdsp_create(str#endif /* no iobox connected, we defer initialization */ snd_printk (KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n" ); -if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) +if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) { +iounmap (hdsp->iobase);return err; + }return 0 ; }else {snd_printk (KERN_INFO "Hammerfall-DSP: Firmware already present, initializing card.\n" );
@@ -4976,8 +4981,10 @@ static int __devinit snd_hdsp_create(str } } -if ((err =snd_hdsp_enable_io (hdsp)) !=0 ) +if ((err =snd_hdsp_enable_io (hdsp)) !=0 ) { +iounmap (hdsp->iobase);return err; + }if (is_9652) hdsp->io_type =H9652 ;
@@ -4985,16 +4992,20 @@ static int __devinit snd_hdsp_create(strif (is_9632) hdsp->io_type =H9632 ; -if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) +if ((err =snd_hdsp_create_hwdep (card, hdsp)) <0 ) { +iounmap (hdsp->iobase);return err; + }snd_hdsp_initialize_channels (hdsp);snd_hdsp_initialize_midi_flush (hdsp); hdsp->state |= HDSP_FirmwareLoaded; -if ((err =snd_hdsp_create_alsa_devices (card, hdsp)) <0 ) +if ((err =snd_hdsp_create_alsa_devices (card, hdsp)) <0 ) { +iounmap (hdsp->iobase);return err; + }return 0 ; }
sound/pci/rme9652/hdspm.c +5 -1
@@ -3500,6 +3500,7 @@ static int __devinit snd_hdspm_create(st IRQF_DISABLED | IRQF_SHARED, "hdspm", (void *) hdspm)) {snd_printk (KERN_ERR "HDSPM: unable to use IRQ %d\n" , pci->irq); +iounmap (hdspm->iobase);return -EBUSY ; }
@@ -3516,6 +3517,7 @@ static int __devinit snd_hdspm_create(st = NULL) {snd_printk (KERN_ERR "HDSPM: unable to kmalloc Mixer memory of %d Bytes\n" , (int )sizeof (struct hdspm_mixer )); +iounmap (hdspm->iobase);return err; }
@@ -3524,8 +3526,10 @@ static int __devinit snd_hdspm_create(st hdspm->qs_channels =MADI_QS_CHANNELS ;snd_printdd ("create alsa devices.\n" ); -if ((err =snd_hdspm_create_alsa_devices (card, hdspm)) <0 ) +if ((err =snd_hdspm_create_alsa_devices (card, hdspm)) <0 ) { +iounmap (hdspm->iobase);return err; + }snd_hdspm_initialize_midi_flush (hdspm);
sound/pci/rme9652/rme9652.c +4 -0
@@ -2502,6 +2502,7 @@ static int __devinit snd_rme9652_create(if (request_irq (pci->irq, snd_rme9652_interrupt,IRQF_DISABLED |IRQF_SHARED ,"rme9652" , (void *)rme9652)) {snd_printk (KERN_ERR "unable to request IRQ %d\n" , pci->irq); +iounmap (rme9652->iobase);return -EBUSY ; } rme9652->irq = pci->irq;
@@ -2562,14 +2563,17 @@ static int __devinit snd_rme9652_create(pci_set_master (rme9652->pci);if ((err =snd_rme9652_initialize_memory (rme9652)) <0 ) { +iounmap (rme9652->iobase);return err; }if ((err =snd_rme9652_create_pcm (card, rme9652)) <0 ) { +iounmap (rme9652->iobase);return err; }if ((err =snd_rme9652_create_controls (card, rme9652)) <0 ) { +iounmap (rme9652->iobase);return err; }
sound/pci/rme96.c +4 -0
@@ -1590,6 +1590,7 @@ snd_rme96_create(struct rme96 *rme96)if (request_irq (pci->irq, snd_rme96_interrupt,IRQF_DISABLED |IRQF_SHARED ,"RME96" , (void *)rme96)) {snd_printk (KERN_ERR "unable to grab IRQ %d\n" , pci->irq); +iounmap (rme96->iobase);return -EBUSY ; } rme96->irq = pci->irq;
@@ -1601,6 +1602,7 @@ snd_rme96_create(struct rme96 *rme96)if ((err =snd_pcm_new (rme96->card,"Digi96 IEC958" ,0 ,1 ,1 , &rme96->spdif_pcm)) <0 ) { +iounmap (rme96->iobase);return err; } rme96->spdif_pcm->private_data = rme96;
@@ -1619,6 +1621,7 @@ snd_rme96_create(struct rme96 *rme96)if ((err =snd_pcm_new (rme96->card,"Digi96 ADAT" ,1 ,1 ,1 , &rme96->adat_pcm)) <0 ) { +iounmap (rme96->iobase);return err; } rme96->adat_pcm->private_data = rme96;
@@ -1671,6 +1674,7 @@ snd_rme96_create(struct rme96 *rme96)/* init switch interface */ if ((err =snd_rme96_create_switches (rme96->card, rme96)) <0 ) { +iounmap (rme96->iobase);return err; }
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [parisc-linux] [PATCH] ioremap balanced with iounmap for
Quoted 3 lines · Amol Lad
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Looks ok. Will merge.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [parisc-linux] [PATCH] ioremap balanced with iounmap for
Quoted 6 lines · Kyle McMartin
Quoted 3 lines · Amol Lad
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Looks ok. Will merge.
Actually, it shows some areas we need to do better. It's an improvement, but look at, eg, the error returns from elroy.
_______________________________________________
Kernel-janitors mailing list [email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [parisc-linux] [PATCH] ioremap balanced with iounmap for drivers/parisc
Quoted 3 lines · Matthew Wilcox
Actually, it shows some areas we need to do better. It's an improvement, but look at, eg, the error returns from elroy.
Agreed.
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux
Re: [parisc-linux] [PATCH] ioremap balanced with iounmap for drivers/parisc
In reply to Kyle McMartinQuoted 6 lines · Kyle McMartin
Quoted 3 lines · Amol Lad
ioremap must be balanced by an iounmap and failing to do so can result in a memory leak.
Looks ok. Will merge.
Actually, it shows some areas we need to do better. It's an improvement, but look at, eg, the error returns from elroy.
_______________________________________________
parisc-linux mailing list [email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux