From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Böszörményi Zoltán" <zboszormenyi@sicom.com>
Cc: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] Input: egalax: potential NULL dereference on error
Date: Sat, 19 Dec 2015 13:58:24 +0300 [thread overview]
Message-ID: <20151219105824.GA3749@mwanda> (raw)
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 <dan.carpenter@oracle.com>
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;
}
next reply other threads:[~2015-12-19 10:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-19 10:58 Dan Carpenter [this message]
2015-12-19 11:04 ` [patch] Input: egalax: potential NULL dereference on error Julia Lawall
2015-12-19 20:04 ` Dan Carpenter
2015-12-19 17:21 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151219105824.GA3749@mwanda \
--to=dan.carpenter@oracle.com \
--cc=dmitry.torokhov@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=zboszormenyi@sicom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).