From patchwork Tue Oct 5 15:20:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 233091 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 o95FMBAl027388 for ; Tue, 5 Oct 2010 15:22:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754265Ab0JEPVO (ORCPT ); Tue, 5 Oct 2010 11:21:14 -0400 Received: from smtp208.alice.it ([82.57.200.104]:40417 "EHLO smtp208.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145Ab0JEPVN (ORCPT ); Tue, 5 Oct 2010 11:21:13 -0400 Received: from jcn (87.1.143.99) by smtp208.alice.it (8.5.124.08) id 4C1A271606F9C2A6; Tue, 5 Oct 2010 17:21:04 +0200 Received: from ao2 by jcn with local (Exim 4.72) (envelope-from ) id 1P39KB-0001lW-LE; Tue, 05 Oct 2010 17:21:03 +0200 From: Antonio Ospite To: linux-input@vger.kernel.org Cc: Antonio Ospite , Jiri Kosina , Alan Ott , Oliver Neukum , linux-kernel@vger.kernel.org, stable@kernel.org Subject: [PATCH 1/2] HID: hidraw, fix a NULL pointer dereference in hidraw_ioctl Date: Tue, 5 Oct 2010 17:20:16 +0200 Message-Id: <1286292017-6746-2-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: 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]); Tue, 05 Oct 2010 15:22:12 +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; }