From patchwork Sat Oct 2 11:25:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 226581 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 o92BPocW003468 for ; Sat, 2 Oct 2010 11:25:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755119Ab0JBLZu (ORCPT ); Sat, 2 Oct 2010 07:25:50 -0400 Received: from smtp205.alice.it ([82.57.200.101]:45474 "EHLO smtp205.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754952Ab0JBLZt (ORCPT ); Sat, 2 Oct 2010 07:25:49 -0400 Received: from jcn (79.2.147.231) by smtp205.alice.it (8.5.124.08) id 4C1A264506BD3E0B; Sat, 2 Oct 2010 13:25:43 +0200 Received: from ao2 by jcn with local (Exim 4.72) (envelope-from ) id 1P20Dm-0001xB-1E; Sat, 02 Oct 2010 13:25:42 +0200 From: Antonio Ospite To: linux-input@vger.kernel.org Cc: Antonio Ospite , Jiri Kosina , Alan Ott , Oliver Neukum , linux-kernel@vger.kernel.org Subject: [PATCH] HID: hidraw, fix a NULL pointer dereference in hidraw_ioctl Date: Sat, 2 Oct 2010 13:25:24 +0200 Message-Id: <1286018724-7484-1-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.1 X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 02 Oct 2010 11:25:51 +0000 (UTC) diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 47d70c5..9eaf6ae 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -244,6 +244,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, mutex_lock(&minors_lock); dev = hidraw_table[minor]; + if (!dev) { + ret = -ENODEV; + goto out; + } switch (cmd) { case HIDIOCGRDESCSIZE: @@ -317,6 +321,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, ret = -ENOTTY; } +out: mutex_unlock(&minors_lock); return ret; }