All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] ati_remote2.c: possible mutex_lock without mutex_unlock
@ 2009-10-13 17:52 ` iceberg
  0 siblings, 0 replies; 7+ messages in thread
From: iceberg @ 2009-10-13 17:52 UTC (permalink / raw)
  To: Vojtech Pavlik, Dmitry Torokhov, Dmitry Torokhov,
	Linux Kernlel Mailing List, linux-input

	KERNEL_VERSION: 2.6.31
	DESCRIBE:

	In driver ./drivers/input/input.c possible call to mutex_lock 
from function input_devices_seq_start without mutex_unlock.

	After calling input_devices_seq_start we can't know whether 
mutex was locked or not. 
Case 1. If mutex_lock_interruptible was not 
locked due to interrupt then input_devices_seq_start returns NULL. 
Case 2. If mutex was successfuly locked but seq_list_start returned 
NULL then input_devices_seq_start returns NULL too. 
The last case occurs if seq_list_start is called with pos>size of 
input_dev_list or pos<0.

Hence, after calling input_devices_seq_start we can not simply check 
that result is not NULL and call input_devices_seq_stop function 
which unlocks the mutex. Because in case 2 the mutex will stay locked.
void * ret = input_devices_seq_start(...);
if(ret!=NULL) {
	//mutex is acquired for sure
	input_devices_seq_stop(...);//unlocks the mutex
} else {
	//mutex may be acquired or not
}

 783 static void *input_devices_seq_start(struct seq_file *seq, loff_t 
*pos)
 784{
 785        if (mutex_lock_interruptible(&input_mutex))
 786                return NULL;
 787
 788        return seq_list_start(&input_dev_list, *pos);
 789}

 663struct list_head *seq_list_start(struct list_head *head, loff_t 
pos)
 664{
 665        struct list_head *lh;
 666
 667        list_for_each(lh, head)
 668                if (pos-- == 0)
 669                        return lh;
 670
 671        return NULL;
 672}
 673
 674EXPORT_SYMBOL(seq_list_start);
 675

Found by: Linux Driver Verification project


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-10-14  7:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-13 17:52 [BUG] ati_remote2.c: possible mutex_lock without mutex_unlock iceberg
2009-10-13 17:52 ` iceberg
2009-10-13 15:43 ` Jiri Kosina
2009-10-14  6:29   ` Dmitry Torokhov
2009-10-14  7:11     ` Jiri Kosina
2009-10-14  7:14       ` Dmitry Torokhov
2009-10-14  7:16         ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.