[PATCH 3/2] pcmcia: don't send ejection requests to userspace [Was: Re: [PATCH 2/2] pcmcia: don't lock up in rsrc_nonstatic pcmcia_validate_mem]

Dominik Brodowski linux at dominikbrodowski.net
Sat Mar 19 07:19:36 EST 2005


On Sat, Mar 19, 2005 at 11:51:09AM +0000, Russell King wrote:
> On Sat, Mar 19, 2005 at 12:28:52PM +0100, Dominik Brodowski wrote:
> > struct socket_data wasn't zeroed, so pcmcia_validate_mem() didn't get called.
> > If it is called, though, one possible code-path already holds skt_sem, so
> > lockups occur. Therefore, change calling conventions to pcmcia_validate_mem().
> 
> Beware - you can get a lockup through cardmgr callbacks.  This is why
> the locking is _inside_ this function, protected against being called
> unnecessarily.
> 
> I suggest you read back on why I ended up modifying it to be this way -
> having gotten bug reports when doing it the way you're now trying to.

Thanks for noticing this. Reading back, I learn that this only happens on
"ejection requests" being sent to userspace. As the very next patch in my
queue [which has already spent some time in -mm] removes this, I suggest to
merge it also into 2.6.12. Then my patch is correct again.



Don't inform cardmgr of ejection requests so that "cardctl eject" behaves
_exactly_ the same as a physical ejection from an userspace point of view.

Removing this allows us to clean up some other code which is otherwise unused.

Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>
Index: 2.6.12-rc1/drivers/pcmcia/ds.c
===================================================================
--- 2.6.12-rc1.orig/drivers/pcmcia/ds.c	2005-03-19 11:53:58.000000000 +0100
+++ 2.6.12-rc1/drivers/pcmcia/ds.c	2005-03-19 11:54:28.000000000 +0100
@@ -91,8 +91,7 @@
 	struct pcmcia_callback	callback;
 	int			state;
 	user_info_t		*user;
-	int			req_pending, req_result;
-	wait_queue_head_t	queue, request;
+	wait_queue_head_t	queue;
 	struct pcmcia_socket	*parent;
 
 	/* the PCMCIA devices connected to this socket (normally one, more
@@ -673,19 +672,6 @@
     wake_up_interruptible(&s->queue);
 }
 
-static int handle_request(struct pcmcia_bus_socket *s, event_t event)
-{
-    if (s->req_pending != 0)
-	return CS_IN_USE;
-    if (s->state & DS_SOCKET_BUSY)
-	s->req_pending = 1;
-    handle_event(s, event);
-    if (wait_event_interruptible(s->request, s->req_pending <= 0))
-        return CS_IN_USE;
-    if (s->state & DS_SOCKET_BUSY)
-        return s->req_result;
-    return CS_SUCCESS;
-}
 
 /*======================================================================
 
@@ -767,9 +753,6 @@
 		break;
 
 	case CS_EVENT_EJECTION_REQUEST:
-		ret = handle_request(s, event);
-		if (ret)
-			break;
 		ret = send_event(skt, event, priority);
 		break;
 
@@ -1216,8 +1199,6 @@
     /* Unlink user data structure */
     if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
 	s->state &= ~DS_SOCKET_BUSY;
-	s->req_pending = 0;
-	wake_up_interruptible(&s->request);
     }
     file->private_data = NULL;
     for (link = &s->user; *link; link = &(*link)->next)
@@ -1266,33 +1247,14 @@
 static ssize_t ds_write(struct file *file, const char __user *buf,
 			size_t count, loff_t *ppos)
 {
-    struct pcmcia_bus_socket *s;
-    user_info_t *user;
-
     ds_dbg(2, "ds_write(socket %d)\n", iminor(file->f_dentry->d_inode));
-    
+
     if (count != 4)
 	return -EINVAL;
     if ((file->f_flags & O_ACCMODE) == O_RDONLY)
 	return -EBADF;
 
-    user = file->private_data;
-    if (CHECK_USER(user))
-	return -EIO;
-
-    s = user->socket;
-    if (s->state & DS_SOCKET_DEAD)
-        return -EIO;
-
-    if (s->req_pending) {
-	s->req_pending--;
-	get_user(s->req_result, (int __user *)buf);
-	if ((s->req_result != 0) || (s->req_pending == 0))
-	    wake_up_interruptible(&s->request);
-    } else
-	return -EIO;
-
-    return 4;
+    return -EIO;
 } /* ds_write */
 
 /*====================================================================*/
@@ -1566,7 +1528,6 @@
 	msleep(250);
 
 	init_waitqueue_head(&s->queue);
-	init_waitqueue_head(&s->request);
 	INIT_LIST_HEAD(&s->devices_list);
 
 	/* Set up hotline to Card Services */



More information about the linux-pcmcia mailing list