linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] Input: egalax: potential NULL dereference on error
@ 2015-12-19 10:58 Dan Carpenter
  2015-12-19 11:04 ` Julia Lawall
  2015-12-19 17:21 ` Dmitry Torokhov
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-12-19 10:58 UTC (permalink / raw)
  To: Dmitry Torokhov, Böszörményi Zoltán
  Cc: linux-input, kernel-janitors

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;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-19 20:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-19 10:58 [patch] Input: egalax: potential NULL dereference on error Dan Carpenter
2015-12-19 11:04 ` Julia Lawall
2015-12-19 20:04   ` Dan Carpenter
2015-12-19 17:21 ` Dmitry Torokhov

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).