]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
Input: rmi4 - refactor function allocation and registration
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 5 May 2026 04:59:40 +0000 (21:59 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 12 Jun 2026 05:39:28 +0000 (22:39 -0700)
commit58d42ec10b7324fa2965d74b9bfbacac3af55c70
tree9cc4e26db0d797985d3ac4b2150dd9e425e9d213
parent4e5336f303e2845a82735b5578f7c0e4a175f8c5
Input: rmi4 - refactor function allocation and registration

Currently, rmi_create_function() allocates memory for the rmi_function
structure, but rmi_register_function() initializes the device via
device_initialize(). This split of ownership makes error handling in
rmi_create_function() confusing because the caller must be aware that
if rmi_register_function() fails, it has already called put_device() to
clean up the memory.

To make the memory lifecycle explicit and fix potential leaks cleanly
introduce rmi_alloc_function() to handle memory allocation and device
initialization, and make the caller of rmi_register_function()
responsible for cleanup.

Assisted-by: Gemini:gemini-3.1-pro
Link: https://patch.msgid.link/20260505045952.1570713-10-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/rmi4/rmi_bus.c
drivers/input/rmi4/rmi_bus.h
drivers/input/rmi4/rmi_driver.c