]> git.itanic.dy.fi Git - linux-stable/commitdiff
Input: synaptics-rmi4 - fix use after free in rmi_unregister_function()
authorDan Carpenter <dan.carpenter@linaro.org>
Sun, 29 Oct 2023 02:53:36 +0000 (02:53 +0000)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 29 Oct 2023 02:54:52 +0000 (02:54 +0000)
The put_device() calls rmi_release_function() which frees "fn" so the
dereference on the next line "fn->num_of_irqs" is a use after free.
Move the put_device() to the end to fix this.

Fixes: 24d28e4f1271 ("Input: synaptics-rmi4 - convert irq distribution to irq_domain")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/706efd36-7561-42f3-adfa-dd1d0bd4f5a1@moroto.mountain
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/rmi4/rmi_bus.c

index f2e093b0b9982d238cca68454c0fbdbef174a81d..1b45b1d3077de72d6f78c608287c52f0d09773f3 100644 (file)
@@ -277,11 +277,11 @@ void rmi_unregister_function(struct rmi_function *fn)
 
        device_del(&fn->dev);
        of_node_put(fn->dev.of_node);
-       put_device(&fn->dev);
 
        for (i = 0; i < fn->num_of_irqs; i++)
                irq_dispose_mapping(fn->irq[i]);
 
+       put_device(&fn->dev);
 }
 
 /**