lkml.org 
[lkml]   [2003]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] raceless request_region() fix (was Re: Linux 2.6.0-test4)
Date
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/

\
 
 \ /
  Last update: 2005-03-22 13:48    [W:0.117 / U:4.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site