The patch titled Char: istallion, correct fail paths has been added to the -mm tree. Its filename is char-istallion-correct-fail-paths.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: Char: istallion, correct fail paths From: Jiri Slaby <jirislaby@xxxxxxxxx> Check more retvals and react somehow. Signed-off-by: Jiri Slaby <jirislaby@xxxxxxxxx> Cc: Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- Makefile | 2 drivers/char/istallion.c | 142 +++++++++++++++++++++---------------- 2 files changed, 82 insertions(+), 62 deletions(-) diff -puN Makefile~char-istallion-correct-fail-paths Makefile --- a/Makefile~char-istallion-correct-fail-paths +++ a/Makefile @@ -313,7 +313,7 @@ LINUXINCLUDE := -Iinclude \ CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ - -fno-strict-aliasing -fno-common + -fno-strict-aliasing -fno-common -W -Wno-unused AFLAGS := -D__ASSEMBLY__ # Read KERNELRELEASE from include/config/kernel.release (if it exists) diff -puN drivers/char/istallion.c~char-istallion-correct-fail-paths drivers/char/istallion.c --- a/drivers/char/istallion.c~char-istallion-correct-fail-paths +++ a/drivers/char/istallion.c @@ -776,11 +776,6 @@ static void __exit istallion_module_exit } i = tty_unregister_driver(stli_serial); - if (i) { - printk("STALLION: failed to un-register tty driver, " - "errno=%d\n", -i); - return; - } put_tty_driver(stli_serial); for (j = 0; j < 4; j++) class_device_destroy(istallion_class, MKDEV(STL_SIOMEMMAJOR, j)); @@ -3278,15 +3273,16 @@ static int stli_initecp(struct stlibrd * cdkecpsig_t __iomem *sigsp; unsigned int status, nxtid; char *name; - int panelnr, nrports; + int retval, panelnr, nrports; - if (!request_region(brdp->iobase, brdp->iosize, "istallion")) - return -EIO; - - if ((brdp->iobase == 0) || (brdp->memaddr == 0)) - { - release_region(brdp->iobase, brdp->iosize); - return -ENODEV; + if ((brdp->iobase == 0) || (brdp->memaddr == 0)) { + retval = -ENODEV; + goto err; + } + + if (!request_region(brdp->iobase, brdp->iosize, "istallion")) { + retval = -EIO; + goto err; } brdp->iosize = ECP_IOSIZE; @@ -3350,8 +3346,8 @@ static int stli_initecp(struct stlibrd * break; default: - release_region(brdp->iobase, brdp->iosize); - return -EINVAL; + retval = -EINVAL; + goto err_reg; } /* @@ -3363,10 +3359,9 @@ static int stli_initecp(struct stlibrd * EBRDINIT(brdp); brdp->membase = ioremap(brdp->memaddr, brdp->memsize); - if (brdp->membase == NULL) - { - release_region(brdp->iobase, brdp->iosize); - return -ENOMEM; + if (brdp->membase == NULL) { + retval = -ENOMEM; + goto err_reg; } /* @@ -3379,12 +3374,9 @@ static int stli_initecp(struct stlibrd * memcpy_fromio(&sig, sigsp, sizeof(cdkecpsig_t)); EBRDDISABLE(brdp); - if (sig.magic != cpu_to_le32(ECP_MAGIC)) - { - release_region(brdp->iobase, brdp->iosize); - iounmap(brdp->membase); - brdp->membase = NULL; - return -ENODEV; + if (sig.magic != cpu_to_le32(ECP_MAGIC)) { + retval = -ENODEV; + goto err_unmap; } /* @@ -3409,6 +3401,13 @@ static int stli_initecp(struct stlibrd * brdp->state |= BST_FOUND; return 0; +err_unmap: + iounmap(brdp->membase); + brdp->membase = NULL; +err_reg: + release_region(brdp->iobase, brdp->iosize); +err: + return retval; } /*****************************************************************************/ @@ -3423,18 +3422,22 @@ static int stli_initonb(struct stlibrd * cdkonbsig_t sig; cdkonbsig_t __iomem *sigsp; char *name; - int i; + int i, retval; /* * Do a basic sanity check on the IO and memory addresses. */ - if (brdp->iobase == 0 || brdp->memaddr == 0) - return -ENODEV; + if (brdp->iobase == 0 || brdp->memaddr == 0) { + retval = -ENODEV; + goto err; + } brdp->iosize = ONB_IOSIZE; - if (!request_region(brdp->iobase, brdp->iosize, "istallion")) - return -EIO; + if (!request_region(brdp->iobase, brdp->iosize, "istallion")) { + retval = -EIO; + goto err; + } /* * Based on the specific board type setup the common vars to access @@ -3500,8 +3503,8 @@ static int stli_initonb(struct stlibrd * break; default: - release_region(brdp->iobase, brdp->iosize); - return -EINVAL; + retval = -EINVAL; + goto err_reg; } /* @@ -3513,10 +3516,9 @@ static int stli_initonb(struct stlibrd * EBRDINIT(brdp); brdp->membase = ioremap(brdp->memaddr, brdp->memsize); - if (brdp->membase == NULL) - { - release_region(brdp->iobase, brdp->iosize); - return -ENOMEM; + if (brdp->membase == NULL) { + retval = -ENOMEM; + goto err_reg; } /* @@ -3532,12 +3534,9 @@ static int stli_initonb(struct stlibrd * if (sig.magic0 != cpu_to_le16(ONB_MAGIC0) || sig.magic1 != cpu_to_le16(ONB_MAGIC1) || sig.magic2 != cpu_to_le16(ONB_MAGIC2) || - sig.magic3 != cpu_to_le16(ONB_MAGIC3)) - { - release_region(brdp->iobase, brdp->iosize); - iounmap(brdp->membase); - brdp->membase = NULL; - return -ENODEV; + sig.magic3 != cpu_to_le16(ONB_MAGIC3)) { + retval = -ENODEV; + goto err_unmap; } /* @@ -3559,6 +3558,13 @@ static int stli_initonb(struct stlibrd * brdp->state |= BST_FOUND; return 0; +err_unmap: + iounmap(brdp->membase); + brdp->membase = NULL; +err_reg: + release_region(brdp->iobase, brdp->iosize); +err: + return retval; } /*****************************************************************************/ @@ -3679,33 +3685,30 @@ stli_donestartup: static int __devinit stli_brdinit(struct stlibrd *brdp) { + int retval; + switch (brdp->brdtype) { case BRD_ECP: case BRD_ECPE: case BRD_ECPMC: case BRD_ECPPCI: - stli_initecp(brdp); + retval = stli_initecp(brdp); break; case BRD_ONBOARD: case BRD_ONBOARDE: case BRD_ONBOARD2: case BRD_BRUMBY4: case BRD_STALLION: - stli_initonb(brdp); + retval = stli_initonb(brdp); break; default: printk(KERN_ERR "STALLION: board=%d is unknown board " "type=%d\n", brdp->brdnr, brdp->brdtype); - return -ENODEV; + retval = -ENODEV; } - if ((brdp->state & BST_FOUND) == 0) { - printk(KERN_ERR "STALLION: %s board not found, board=%d " - "io=%x mem=%x\n", - stli_brdnames[brdp->brdtype], brdp->brdnr, - brdp->iobase, (int) brdp->memaddr); - return -ENODEV; - } + if (retval) + return retval; stli_initports(brdp); printk(KERN_INFO "STALLION: %s found, board=%d io=%x mem=%x " @@ -3842,7 +3845,7 @@ static int stli_findeisabrds(void) { struct stlibrd *brdp; unsigned int iobase, eid, i; - int brdnr; + int brdnr, found = 0; /* * Firstly check if this is an EISA system. If this is not an EISA system then @@ -3880,10 +3883,10 @@ static int stli_findeisabrds(void) * Allocate a board structure and initialize it. */ if ((brdp = stli_allocbrd()) == NULL) - return -ENOMEM; + return found ? : -ENOMEM; brdnr = stli_getbrdnr(); if (brdnr < 0) - return -ENOMEM; + return found ? : -ENOMEM; brdp->brdnr = (unsigned int)brdnr; eid = inb(iobase + 0xc82); if (eid == ECP_EISAID) @@ -3896,11 +3899,16 @@ static int stli_findeisabrds(void) outb(0x1, (iobase + 0xc84)); if (stli_eisamemprobe(brdp)) outb(0, (iobase + 0xc84)); + if (stli_brdinit(brdp) < 0) { + kfree(brdp); + continue; + } + stli_brds[brdp->brdnr] = brdp; - stli_brdinit(brdp); + found++; } - return 0; + return found; } #else static inline int stli_findeisabrds(void) { return 0; } @@ -4020,7 +4028,7 @@ static int stli_initbrds(void) { struct stlibrd *brdp, *nxtbrdp; struct stlconf conf; - unsigned int i, j; + unsigned int i, j, found = 0; int retval; for (stli_nrbrds = 0; stli_nrbrds < ARRAY_SIZE(stli_brdsp); @@ -4034,14 +4042,24 @@ static int stli_initbrds(void) brdp->brdtype = conf.brdtype; brdp->iobase = conf.ioaddr1; brdp->memaddr = conf.memaddr; + if (stli_brdinit(brdp) < 0) { + kfree(brdp); + continue; + } stli_brds[brdp->brdnr] = brdp; - stli_brdinit(brdp); + found++; } - stli_findeisabrds(); + retval = stli_findeisabrds(); + if (retval > 0) + found += retval; retval = pci_register_driver(&stli_pcidriver); - /* TODO: check retval and do something */ + if (retval && found == 0) { + printk(KERN_ERR "Neither isa nor eisa cards found nor pci " + "driver can be registered!\n"); + goto err; + } /* * All found boards are initialized. Now for a little optimization, if @@ -4082,6 +4100,8 @@ static int stli_initbrds(void) } return 0; +err: + return retval; } /*****************************************************************************/ _ Patches currently in -mm which might be from jirislaby@xxxxxxxxx are mxser-correct-tty-driver-name.patch pci-mxser-pci-refcounts.patch mxser-make-an-experimental-clone.patch char-mxser_new-correct-include-file.patch char-mxser_new-upgrade-to-191.patch char-mxser_new-rework-to-allow-dynamic-structs.patch char-mxser_new-use-__devinit-macros.patch char-mxser_new-pci_request_region-for-pci-regions.patch char-mxser_new-check-request_region-retvals.patch char-mxser_new-kill-unneeded-memsets.patch char-mxser_new-revert-spin_lock-changes.patch char-mxser_new-remove-request-for-testers-line.patch char-mxser_new-debug-printk-dependent-on-debug.patch char-mxser_new-alter-license-terms.patch char-mxser_new-code-upside-down.patch char-mxser_new-cmspar-is-defined.patch char-remove-unneded-termbits-redefinitions-mxser_new.patch char-mxser_new-eliminate-tty-ldisc-deref.patch char-mxser_new-testbit-for-bit-testing.patch char-mxser_new-correct-fail-paths.patch char-mxser_new-dont-check-tty_unregister-retval.patch char-mxser_new-compress-isa-finding.patch char-mxser_new-register-tty-devices-on-the-fly.patch char-mxser_new-compact-structures-round2.patch char-mxser_new-reverse-if-else-paths-patch.patch char-mxser_new-comments-cleanup.patch char-mxser_new-correct-intr-handler-proto.patch char-mxser_new-delete-ttys-and-termios.patch char-mxser_new-pci-probing.patch char-mxser_new-clean-macros.patch maintainers-add-me-to-isicom-mxser.patch mxser_new-correct-tty-driver-name.patch char-stallion-use-pr_debug-macro.patch char-stallion-remove-unneeded-casts.patch char-stallion-kill-typedefs.patch char-stallion-move-init-deinit.patch char-stallion-uninline-functions.patch char-stallion-mark-functions-as-init.patch char-stallion-remove-many-prototypes.patch char-isicom-expand-function.patch char-isicom-rename-init-function.patch char-isicom-remove-isa-code.patch char-isicom-remove-unneeded-memset.patch char-isicom-move-to-tty_register_device.patch char-isicom-use-pci_request_region.patch char-isicom-check-kmalloc-retval.patch char-isicom-use-completion.patch char-isicom-simplify-timer.patch char-isicom-remove-cvs-stuff.patch char-isicom-fix-tty-index-check.patch char-sx-convert-to-pci-probing.patch char-sx-use-kcalloc.patch char-sx-mark-functions-as-devinit.patch char-sx-use-eisa-probing.patch char-sx-ifdef-isa-code.patch char-sx-lock-boards-struct.patch char-sx-remove-duplicite-code.patch char-sx-whitespace-cleanup.patch char-sx-simplify-timer-logic.patch char-sx-fix-return-in-module-init.patch char-sx-use-pci_iomap.patch char-sx-request-regions.patch char-stallion-convert-to-pci-probing.patch char-stallion-prints-cleanup.patch char-stallion-implement-fail-paths.patch char-stallion-correct-__init-macros.patch char-stallion-functions-cleanup.patch char-stallion-fix-fail-paths.patch char-stallion-brd-struct-locking.patch char-stallion-remove-syntactic-sugar.patch char-stallion-variables-cleanup.patch char-stallion-use-dynamic-dev.patch char-istallion-convert-to-pci-probing.patch char-istallion-remove-the-mess.patch char-istallion-eliminate-typedefs.patch char-istallion-variables-cleanup.patch char-istallion-ifdef-eisa-code.patch char-istallion-brdnr-locking.patch char-istallion-free-only-isa.patch char-istallion-correct-fail-paths.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html