• Jason Gerecke's avatar
    HID: wacom: Properly free inputs if 'wacom_allocate_inputs' fails · d9f2d203
    Jason Gerecke authored
    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 67e123ff ("Delete
     unnecessary checks")]
    Signed-off-by: default avatarJason Gerecke <jason.gerecke@wacom.com>
    Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
    d9f2d203
wacom_sys.c 44.1 KB