From patchwork Tue Oct 13 15:43:44 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Kosina X-Patchwork-Id: 53435 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9DFqQm0000982 for ; Tue, 13 Oct 2009 15:52:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760358AbZJMPoX (ORCPT ); Tue, 13 Oct 2009 11:44:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1760332AbZJMPoW (ORCPT ); Tue, 13 Oct 2009 11:44:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:40048 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760290AbZJMPoV (ORCPT ); Tue, 13 Oct 2009 11:44:21 -0400 Received: from relay2.suse.de (relay-ext.suse.de [195.135.221.8]) by mx2.suse.de (Postfix) with ESMTP id C8E4C867E2; Tue, 13 Oct 2009 17:43:44 +0200 (CEST) Date: Tue, 13 Oct 2009 17:43:44 +0200 (CEST) From: Jiri Kosina X-X-Sender: jkosina@wotan.suse.de To: iceberg , Dmitry Torokhov Cc: Vojtech Pavlik , Dmitry Torokhov , Linux Kernlel Mailing List , linux-input@vger.kernel.org Subject: Re: [BUG] ati_remote2.c: possible mutex_lock without mutex_unlock In-Reply-To: <1255456327.22233.0@pamir> Message-ID: References: <1255456327.22233.0@pamir> User-Agent: Alpine 2.00 (LSU 1167 2008-08-23) MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/input/input.c b/drivers/input/input.c index c6f88eb..ef4d5c1 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -882,7 +882,7 @@ static const struct file_operations input_devices_fileops = { static void *input_handlers_seq_start(struct seq_file *seq, loff_t *pos) { if (mutex_lock_interruptible(&input_mutex)) - return NULL; + return ERR_PTR(-EAGAIN); seq->private = (void *)(unsigned long)*pos; return seq_list_start(&input_handler_list, *pos); @@ -896,6 +896,10 @@ static void *input_handlers_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void input_handlers_seq_stop(struct seq_file *seq, void *v) { + /* seq_start could get interrupted by signal before acquiring mutex */ + if (IS_ERR(v) && ERR_PTR(v) == -EAGAIN) + return; + mutex_unlock(&input_mutex); }