From patchwork Tue Oct 19 09:24:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 265141 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9J9rLq1005801 for ; Tue, 19 Oct 2010 09:53:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758119Ab0JSJxU (ORCPT ); Tue, 19 Oct 2010 05:53:20 -0400 Received: from minas.ics.muni.cz ([147.251.4.40]:37638 "EHLO minas.ics.muni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756596Ab0JSJxT (ORCPT ); Tue, 19 Oct 2010 05:53:19 -0400 Received: from anxur.fi.muni.cz (anxur.fi.muni.cz [147.251.48.3]) by minas.ics.muni.cz (8.13.8/8.13.8/SuSE Linux 0.8) with ESMTP id o9J9Ojog003347; Tue, 19 Oct 2010 11:24:46 +0200 Received: from anemoi.fi.muni.cz (wired-221.fi.muni.cz [147.251.46.221]) by anxur.fi.muni.cz (Postfix) with ESMTP id 82D3D70023; Tue, 19 Oct 2010 11:24:45 +0200 (CEST) From: Jiri Slaby To: jkosina@suse.cz Cc: alan@signal11.us, linux-input@vger.kernel.org, jirislaby@gmail.com, linux-kernel@vger.kernel.org, Jiri Slaby Subject: [PATCH 1/1] HID: hidraw, fix window in hidraw_release Date: Tue, 19 Oct 2010 11:24:45 +0200 Message-Id: <1287480285-5335-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <20101009144026.c37f8d25.ospite@studenti.unina.it> References: <20101009144026.c37f8d25.ospite@studenti.unina.it> X-Muni-Spam-TestIP: 147.251.48.3 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 19 Oct 2010 09:53:21 +0000 (UTC) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (minas.ics.muni.cz [147.251.4.35]); Tue, 19 Oct 2010 11:24:47 +0200 (CEST) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 925992f..6d81be3 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -218,9 +218,13 @@ static int hidraw_release(struct inode * inode, struct file * file) unsigned int minor = iminor(inode); struct hidraw *dev; struct hidraw_list *list = file->private_data; + int ret; - if (!hidraw_table[minor]) - return -ENODEV; + mutex_lock(&minors_lock); + if (!hidraw_table[minor]) { + ret = -ENODEV; + goto unlock; + } list_del(&list->node); dev = hidraw_table[minor]; @@ -233,10 +237,12 @@ static int hidraw_release(struct inode * inode, struct file * file) kfree(list->hidraw); } } - + ret = 0; +unlock: + mutex_unlock(&minors_lock); kfree(list); - return 0; + return ret; } static long hidraw_ioctl(struct file *file, unsigned int cmd,