From patchwork Sat Dec 19 10:58:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 7890051 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A672EBEEE5 for ; Sat, 19 Dec 2015 10:58:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E44C02047B for ; Sat, 19 Dec 2015 10:58:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD43420465 for ; Sat, 19 Dec 2015 10:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932714AbbLSK6o (ORCPT ); Sat, 19 Dec 2015 05:58:44 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:27053 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750931AbbLSK6n (ORCPT ); Sat, 19 Dec 2015 05:58:43 -0500 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id tBJAwXdd032149 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 19 Dec 2015 10:58:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id tBJAwXEh011652 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 19 Dec 2015 10:58:33 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id tBJAwWnE018550; Sat, 19 Dec 2015 10:58:33 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 19 Dec 2015 02:58:31 -0800 Date: Sat, 19 Dec 2015 13:58:24 +0300 From: Dan Carpenter To: Dmitry Torokhov , =?iso-8859-1?B?QvZzevZybelueWkgWm9sdOFu?= Cc: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch] Input: egalax: potential NULL dereference on error Message-ID: <20151219105824.GA3749@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We didn't check input_allocate_device() for failures so it could lead to a NULL deref. Fixes: 6b0f8f9c52ef ('Input: add eGalaxTouch serial touchscreen driver') Signed-off-by: Dan Carpenter --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/touchscreen/egalax_ts_serial.c b/drivers/input/touchscreen/egalax_ts_serial.c index a078c1c..8becd26 100644 --- a/drivers/input/touchscreen/egalax_ts_serial.c +++ b/drivers/input/touchscreen/egalax_ts_serial.c @@ -104,10 +104,13 @@ static int egalax_connect(struct serio *serio, struct serio_driver *drv) int error; egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL); + if (!egalax) + return -ENOMEM; + input_dev = input_allocate_device(); - if (!egalax) { + if (!input_dev) { error = -ENOMEM; - goto err_free_mem; + goto err_free_egalax; } egalax->serio = serio; @@ -145,8 +148,8 @@ err_close_serio: serio_close(serio); err_reset_drvdata: serio_set_drvdata(serio, NULL); -err_free_mem: input_free_device(input_dev); +err_free_egalax: kfree(egalax); return error; }