From: Russell King <rmk@arm.linux.org.uk>
To: Linux Kernel List <linux-kernel@vger.kernel.org>
Cc: Dominik Brodowski <linux@brodo.de>, linux-pcmcia@lists.infradead.org
Subject: [PATCH] Prevent sysfs-related oops in pcmcia class code
Date: Sun, 15 Jun 2003 18:08:27 +0100 [thread overview]
Message-ID: <20030615180827.E5417@flint.arm.linux.org.uk> (raw)
Although no such oops has been reported, removing a socket driver
while a file under /sysfs/class/pcmcia_socket/pcmcia_socket* is
held open by user space could potentially cause an oops.
Plug this by preventing pcmcia_unregister_socket from returning
until all references by sysfs to the pcmcia socket have been
dropped.
This patch is against my current bk tree, so will apply with offsets
to 2.5.71.
diff -Nru a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
--- a/drivers/pcmcia/cs.c Sun Jun 15 18:05:06 2003
+++ b/drivers/pcmcia/cs.c Sun Jun 15 18:05:06 2003
@@ -387,6 +387,12 @@
socket->ss_entry = NULL;
}
+static void pcmcia_release_socket(struct class_device *class_dev)
+{
+ struct pcmcia_socket *socket = class_get_devdata(class_dev);
+ complete(&socket->socket_released);
+}
+
/**
* pcmcia_register_socket - add a new pcmcia socket device
@@ -450,6 +456,8 @@
DEBUG(0, "cs: pcmcia_unregister_socket(0x%p)\n", socket->ss_entry);
+ init_completion(&socket->socket_released);
+
/* remove from the device core */
class_device_unregister(&socket->dev);
@@ -457,6 +465,9 @@
down_write(&pcmcia_socket_list_rwsem);
list_del(&socket->socket_list);
up_write(&pcmcia_socket_list_rwsem);
+
+ /* wait for sysfs to drop all references */
+ wait_for_completion(&socket->socket_released);
} /* pcmcia_unregister_socket */
EXPORT_SYMBOL(pcmcia_unregister_socket);
@@ -2496,6 +2507,7 @@
struct class pcmcia_socket_class = {
.name = "pcmcia_socket",
+ .release = pcmcia_release_socket,
};
EXPORT_SYMBOL(pcmcia_socket_class);
diff -Nru a/include/pcmcia/ss.h b/include/pcmcia/ss.h
--- a/include/pcmcia/ss.h Sun Jun 15 18:05:06 2003
+++ b/include/pcmcia/ss.h Sun Jun 15 18:05:06 2003
@@ -193,6 +193,7 @@
char *fake_cis;
struct list_head socket_list;
+ struct completion socket_released;
/* deprecated */
unsigned int sock; /* socket number */
--
Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
reply other threads:[~2003-06-15 16:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20030615180827.E5417@flint.arm.linux.org.uk \
--to=rmk@arm.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pcmcia@lists.infradead.org \
--cc=linux@brodo.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox