lkml.org 
[lkml]   [2003]   [Jun]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Prevent sysfs-related oops in pcmcia class code
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

-
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:36    [W:0.042 / U:0.616 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site