From: Rusty Russell <rusty@rustcorp.com.au>
To: linux-kernel@vger.kernel.org
Cc: torvalds@transmeta.com, dhinds@zen.stanford.edu,
alan@lxorguk.ukuu.org.uk
Subject: [PATCH] Get rid of check_resource() before it becomes a problem
Date: Wed, 30 Oct 2002 12:40:14 +1100 [thread overview]
Message-ID: <20021030014105.1A9F82C47A@lists.samba.org> (raw)
AFAICT, it has the same race issues as the old check_region() which is
being slowly and painfully eliminated.
Remove the temptation, and open-code the one user (PCMCIA).
Rusty.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.44/drivers/pcmcia/rsrc_mgr.c working-2.5.44-proc-register/drivers/pcmcia/rsrc_mgr.c
--- linux-2.5.44/drivers/pcmcia/rsrc_mgr.c 2002-10-15 15:29:59.000000000 +1000
+++ working-2.5.44-proc-register/drivers/pcmcia/rsrc_mgr.c 2002-10-30 12:35:20.000000000 +1100
@@ -124,16 +124,36 @@ static struct resource *resource_parent(
return &ioport_resource;
}
+/* FIXME: Fundamentally racy. */
static inline int check_io_resource(unsigned long b, unsigned long n,
struct pci_dev *dev)
{
- return check_resource(resource_parent(b, n, IORESOURCE_IO, dev), b, n);
+ struct resource *region;
+
+ region = __request_region(resource_parent(b, n, IORESOURCE_IO, dev),
+ b, n, "check_io_resource");
+ if (!region)
+ return -EBUSY;
+
+ release_resource(region);
+ kfree(region);
+ return 0;
}
+/* FIXME: Fundamentally racy. */
static inline int check_mem_resource(unsigned long b, unsigned long n,
struct pci_dev *dev)
{
- return check_resource(resource_parent(b, n, IORESOURCE_MEM, dev), b, n);
+ struct resource *region;
+
+ region = __request_region(resource_parent(b, n, IORESOURCE_MEM, dev),
+ b, n, "check_mem_resource");
+ if (!region)
+ return -EBUSY;
+
+ release_resource(region);
+ kfree(region);
+ return 0;
}
static struct resource *make_resource(unsigned long b, unsigned long n,
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.44/include/linux/ioport.h working-2.5.44-proc-register/include/linux/ioport.h
--- linux-2.5.44/include/linux/ioport.h 2002-05-09 12:40:19.000000000 +1000
+++ working-2.5.44-proc-register/include/linux/ioport.h 2002-10-30 12:25:54.000000000 +1100
@@ -85,7 +85,6 @@ extern struct resource iomem_resource;
extern int get_resource_list(struct resource *, char *buf, int size);
-extern int check_resource(struct resource *root, unsigned long, unsigned long);
extern int request_resource(struct resource *root, struct resource *new);
extern int release_resource(struct resource *new);
extern int allocate_resource(struct resource *root, struct resource *new,
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.44/kernel/resource.c working-2.5.44-proc-register/kernel/resource.c
--- linux-2.5.44/kernel/resource.c 2002-08-11 15:31:43.000000000 +1000
+++ working-2.5.44-proc-register/kernel/resource.c 2002-10-30 12:26:12.000000000 +1100
@@ -131,20 +131,6 @@ int release_resource(struct resource *ol
return retval;
}
-int check_resource(struct resource *root, unsigned long start, unsigned long len)
-{
- struct resource *conflict, tmp;
-
- tmp.start = start;
- tmp.end = start + len - 1;
- write_lock(&resource_lock);
- conflict = __request_resource(root, &tmp);
- if (!conflict)
- __release_resource(&tmp);
- write_unlock(&resource_lock);
- return conflict ? -EBUSY : 0;
-}
-
/*
* Find empty slot in the resource tree given range and alignment.
*/
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
next reply other threads:[~2002-10-30 1:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-30 1:40 Rusty Russell [this message]
2002-10-30 2:33 ` [PATCH] Get rid of check_resource() before it becomes a problem Jeff Garzik
2002-10-30 3:15 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021030014105.1A9F82C47A@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=dhinds@zen.stanford.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.