]> git.baikalelectronics.ru Git - kernel.git/commit
HID: wacom: Properly free inputs if 'wacom_allocate_inputs' fails
authorJason Gerecke <killertofu@gmail.com>
Tue, 14 Jul 2015 01:03:44 +0000 (18:03 -0700)
committerJiri Kosina <jkosina@suse.com>
Fri, 17 Jul 2015 09:24:28 +0000 (11:24 +0200)
commit3d9b7cd3cdc2f9cb0e16e8f5e4e5efbe9b4d10c3
tree7c54c2885bf835fc03c41027ae303e49ae8c3cbe
parent49aab90a3d1282944dd4683ed625612533f9c1e7
HID: wacom: Properly free inputs if 'wacom_allocate_inputs' fails

The 'wacom_allocate_inputs' function tries to allocate three input devices: one
each for the pen, touch, and pad. The pointers that are returned by the
'wacom_allocate_input' calls are temporarily stored to local variables where
they are checked to ensure they're non-null before storing them in the
'wacom_wac' structure. If an allocation fails,  the 'wacom_free_inputs'
function is called to reclaim the memory. Unfortunately, 'wacom_free_inputs' is
called prior to the pointers being copied, so it is not actually able to free
anything.

This patch has the calls to 'wacom_allocate_input' store the pointer directly
in the 'wacom_wac' structure where they can be freed. Also, it replaces the
call to 'wacom_free_inputs' with the (more general) 'wacom_clean_inputs' and
removes the no-longer-used function.

[jkosina@suse.com: modify to resolve conflict with 99eda9d ("Delete
 unnecessary checks")]

Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/wacom_sys.c