Input: synaptics-rmi4 - fix handling failures from rmi_enable_sensor
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 24 Mar 2017 21:28:28 +0000 (14:28 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 3 Apr 2017 23:23:59 +0000 (16:23 -0700)
If rmi_enable_sensor() fails in rmi_driver_probe(), we should not return
immediately, but disable IRQs and tear down function list.

Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/rmi4/rmi_driver.c

index d64fc92..821dc47 100644 (file)
@@ -1234,16 +1234,21 @@ static int rmi_driver_probe(struct device *dev)
        if (retval < 0)
                goto err_destroy_functions;
 
-       if (data->f01_container->dev.driver)
+       if (data->f01_container->dev.driver) {
                /* Driver already bound, so enable ATTN now. */
-               return rmi_enable_sensor(rmi_dev);
+               retval = rmi_enable_sensor(rmi_dev);
+               if (retval)
+                       goto err_disable_irq;
+       }
 
        return 0;
 
+err_disable_irq:
+       rmi_disable_irq(rmi_dev, false);
 err_destroy_functions:
        rmi_free_function_list(rmi_dev);
 err:
-       return retval < 0 ? retval : 0;
+       return retval;
 }
 
 static struct rmi_driver rmi_physical_driver = {