Skip to contentSkip to conversation

Is this a preempt issue in drivers/input/evdev.c

DISCUSSION Yin,Fengwei 3 participants 3 messages May 12, 2007 – May 13, 2007

lore
Share & tools
lore
#0 lore raw

Hi,
When open/close evdev, the code is as following to handle multi-client operation:
static int evdev_release(...)

{
	...
	if (!--evdev->open) {
		<------------preempted
		if (evdev->exist)
			input_close_device(...);
		else
			evdev_free(evdev);
	}
	return 0;
}

static int evdev_open(...)

{
	...
	if (!evdev->open++ && evdev->exist){
		errror = input_open_device(...);
		if (error) {
			...
		}
	}
	...
	return 0;
}

So if the evdev_release() is preempted at the point marked by another process which will open the evdev, which will make operation sequence like:

--evdev->open in evdev_release()

         -----> preempted
	                            evdev->open++ and input_open_devie()
	 <----- reschedule 
	input_close_device()

Should we introduce a mutex here? Or do I miss something? Thanks.

Regards
Yin, Fengwei

#1 lore raw

Hi,

Quoted 5 lines · Yin,Fengwei

So if the evdev_release() is preempted at the point marked by another process which will open the evdev, which will make operation sequence like:

Quoted 8 lines
   --evdev->open in evdev_release()
         -----> preempted
	                            evdev->open++ and input_open_devie()
	 <----- reschedule 
	input_close_device()

Should we introduce a mutex here? Or do I miss something? Thanks.

Locking is completely absent in evdev. There was a patch introducing locking in recent -mm's but it got dropped. I need to refresh it.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 14 lines · Dmitry Torokhov

Hi,

Quoted 11 lines · Yin,Fengwei

So if the evdev_release() is preempted at the point marked by another process which will open the evdev, which will make operation sequence like:

   --evdev->open in evdev_release()
         -----> preempted
	                            evdev->open++ and input_open_devie()
	 <----- reschedule 
	input_close_device()
Quoted 5 lines
Quoted 2 lines

Should we introduce a mutex here? Or do I miss something? Thanks.

Locking is completely absent in evdev. There was a patch introducing locking in recent -mm's but it got dropped. I need to refresh it.

How did stuff like that ever get merged, btw? I still have a completely trivially oopsable rmmod psmouse problem, I hope it'll get fixed for 2.6.22.

Signature · 1 line
Jens Axboe