Input: egalax_ts_serial - fix potential NULL dereference on error
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 19 Dec 2015 17:22:21 +0000 (09:22 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 20 Dec 2015 07:44:40 +0000 (23:44 -0800)
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>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/egalax_ts_serial.c

index a078c1c2c3f918df89f54bc635d34e701add5160..657bbae608c8d1f5eb3ce78aebf1b3dc5691100a 100644 (file)
@@ -105,7 +105,7 @@ static int egalax_connect(struct serio *serio, struct serio_driver *drv)
 
        egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL);
        input_dev = input_allocate_device();
-       if (!egalax) {
+       if (!egalax || !input_dev) {
                error = -ENOMEM;
                goto err_free_mem;
        }