From patchwork Tue Oct 19 09:29:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 265071 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 o9J9U2Ql024778 for ; Tue, 19 Oct 2010 09:30:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933461Ab0JSJaA (ORCPT ); Tue, 19 Oct 2010 05:30:00 -0400 Received: from minas.ics.muni.cz ([147.251.4.40]:52021 "EHLO minas.ics.muni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933423Ab0JSJaA (ORCPT ); Tue, 19 Oct 2010 05:30:00 -0400 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:30:02 +0000 (UTC) X-Greylist: delayed 309 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 Oct 2010 05:30:00 EDT 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 o9J9TtwL012227; Tue, 19 Oct 2010 11:29:56 +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 16D2C70026; Tue, 19 Oct 2010 11:29:55 +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:29:55 +0200 Message-Id: <1287480595-5627-1-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1287480285-5335-1-git-send-email-jslaby@suse.cz> References: <1287480285-5335-1-git-send-email-jslaby@suse.cz> X-Muni-Spam-TestIP: 147.251.48.3 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:29:56 +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..8a4b32d 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); } } - kfree(list); + ret = 0; +unlock: + mutex_unlock(&minors_lock); - return 0; + return ret; } static long hidraw_ioctl(struct file *file, unsigned int cmd,