Re: [BUG] ati_remote2.c: possible mutex_lock without mutex_unlock

From: Jiri Kosina
Date: Wed Oct 14 2009 - 03:12:24 EST


On Tue, 13 Oct 2009, Dmitry Torokhov wrote:

> Umm, I don't like assuming that EAGAIN can only mean that
> mutex_lock_interruptible() failed, seq_file core may theoretically
> return -EAGAIN too. In fact, looking through seq_file.c traverse() does
> return -EAGAIN in certain cases...

Damn, you are right -- I explicitly checked for this, but have completely
overlooked the "Eoveflow:" branch in traverse(), which returns EAGAIN. So
my previous patch is of course incorrect.

> Input: fix locking issue in /proc/bus/input/ handlers
>
> From: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
>
> input_devices_seq_start() uses mutex_lock_interruptible() to acquire
> the input_mutex, but doesn't properly handle the situation when the
> call fails (for example due to interrupt). Instead of returning NULL
> (which indicates that there is no more data) we should return
> ERR_PTR()-encoded error.
>
> We also need explicit flag indicating whether input_mutex was acquired
> since input_devices_seq_stop() is called whether input_devices_seq_start()
> was successful or not.
>
> The same applies to input_handlers_seq_start().
>
> Reported-by: iceberg <strakh@xxxxxxxxx>
> Signed-off-by: Dmitry Torokhov <dtor@xxxxxxx>

Yup, looks OK to me.

--
Jiri Kosina
SUSE Labs, Novell Inc.
--
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/