[PATCH] uinput crash maybe this is the FIX

From: emard
Date: Sun Oct 16 2005 - 17:12:31 EST


HI

THanks for all the hints.

Here's my fix for the situation in the uinput.
It generally breaks when Force feedback is removed,
sometimes request id slot is not freed correctly and
it can lead to crash and/or running out of slots.

Without knowing much what I'm doing, I added one
lock and it seems to fix the problem.

Please check is this the right approach on how to do
this locks....

--- linux-2.6.13.4/drivers/input/misc/uinput.c.orig 2005-10-15 10:09:38.000000000 +0200
+++ linux-2.6.13.4/drivers/input/misc/uinput.c 2005-10-16 23:54:20.000000000 +0200
@@ -90,10 +90,16 @@ static inline int uinput_request_reserve

static void uinput_request_done(struct uinput_device *udev, struct uinput_request *request)
{
+ int id;
+
+ spin_lock(&udev->requests_lock);
+ id = request->id;
+ spin_unlock(&udev->requests_lock);
complete(&request->done);

/* Mark slot as available */
- udev->requests[request->id] = NULL;
+ if(id >= 0 && id < UINPUT_NUM_REQUESTS)
+ udev->requests[id] = NULL;
wake_up_interruptible(&udev->requests_waitq);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/