[PATCH] raceless request_region() fix (was Re: Linux 2.6.0-test4)

From: insecure (insecure_at_mail.od.ua)
Date: 08/25/03

  • Next message: Norbert Preining: "2.4.22 tar ball misses drivers/scsi/aic79xx"
    To: Jeff Garzik <jgarzik@pobox.com>, Linus Torvalds <torvalds@osdl.org>, Kernel Mailing List <linux-kernel@vger.kernel.org>
    Date:	Tue, 26 Aug 2003 00:26:47 +0300
    
    

    On Tuesday 26 August 2003 00:20, insecure wrote:
    > > o [arcnet com90io] replace check_region with temporary
    > > request_region, in probe phase.
    >
    > check_region() is deprecated because it is racy.
    > Replacing it with request_region in probe:
    >
    > int probe() {
    > if(!request_region(...))
    > return 0;
    > /* probe */
    > release_region(...);
    > }
    >
    > int init() {
    > request_region(...);
    > }
    >
    > only removes 'deprecated' warning. Race remains.

    Corrected com90io.c patch is below.

    -- 
    vda
    --- linux-2.6.0-test4/drivers/net/arcnet/com90io.c.orig	Sat Aug 23 02:53:52 2003
    +++ linux-2.6.0-test4/drivers/net/arcnet/com90io.c	Tue Aug 26 00:22:51 2003
    @@ -158,7 +158,7 @@
     		       "must specify the base address!\n");
     		return -ENODEV;
     	}
    -	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "com90io probe")) {
    +	if (!request_region(ioaddr, ARCNET_TOTAL_SIZE, "arcnet (COM90xx-IO)")) {
     		BUGMSG(D_INIT_REASONS, "IO check_region %x-%x failed.\n",
     		       ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
     		return -ENXIO;
    @@ -218,7 +218,6 @@
     			goto err_out;
     		}
     	}
    -	release_region(ioaddr, ARCNET_TOTAL_SIZE); /* end of probing */
     	return com90io_found(dev);
     
     err_out:
    @@ -237,13 +236,9 @@
     	/* Reserve the irq */
     	if (request_irq(dev->irq, &arcnet_interrupt, 0, "arcnet (COM90xx-IO)", dev)) {
    +		release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
     		BUGMSG(D_NORMAL, "Can't get IRQ %d!\n", dev->irq);
     		return -ENODEV;
    -	}
    -	/* Reserve the I/O region - guaranteed to work by check_region */
    -	if (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE, "arcnet (COM90xx-IO)")) {
    -		free_irq(dev->irq, dev);
    -		return -EBUSY;
     	}
     	/* Initialize the rest of the device structure. */
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Norbert Preining: "2.4.22 tar ball misses drivers/scsi/aic79xx"

    Relevant Pages

    • Re: Linux 2.6.0-test4
      ... Replacing it with request_region in probe: ... int probe() { ... int init() { ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • [patch] 2.6.8-rc4-mm1: i2c-keywest.c compile error
      ... +static int probe; ... MODULE_DESCRIPTION("I2C driver for Apple's Keywest"); ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)