Input: synaptics-rmi4 – fix possible double free [Linux 5.1]

Input: synaptics-rmi4 – fix possible double free [Linux 5.1]

This Linux kernel change "Input: synaptics-rmi4 – fix possible double free" is included in the Linux 5.1 release. This change is authored by Pan Bian <bianpan2016 [at]> on Fri Apr 19 07:39:00 2019 +0000. The commit for this change in Linux stable tree is bce1a78 (patch).

Input: synaptics-rmi4 - fix possible double free

The RMI4 function structure has been released in rmi_register_function
if error occurs. However, it will be released again in the function
rmi_create_function, which may result in a double-free bug.

Signed-off-by: Pan Bian <>
Signed-off-by: Dmitry Torokhov <>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/input/rmi4/rmi_driver.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index fc3ab93..7fb358f 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -860,7 +860,7 @@ static int rmi_create_function(struct rmi_device *rmi_dev,

    error = rmi_register_function(fn);
    if (error)
-       goto err_put_fn;
+       return error;

    if (pdt->function_number == 0x01)
        data->f01_container = fn;
@@ -870,10 +870,6 @@ static int rmi_create_function(struct rmi_device *rmi_dev,
    list_add_tail(&fn->node, &data->function_list);

-   put_device(&fn->dev);
-   return error;

 void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake)

Leave a Reply

Your email address will not be published. Required fields are marked *