lkml.org 
[lkml]   [2023]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/2] Input: add Himax HX852x(ES) touchscreen driver
From
Le 17/09/2023 à 18:37, Jeff LaBundy a écrit :

>>> + error = input_register_device(hx->input_dev);
>>> + if (error) {
>>
>> input_mt_destroy_slots() should be called here, or in an error handling path
>> below, or via a devm_add_action_or_reset().
>
> This seems like a memory leak in every touchscreen driver; maybe it is more
> practical to have the input core handle this clean-up.
>
> Other drivers can and do insert other return paths between input_mt_init_slots()
> and input_register_device(), so it seems that we cannot solve this by calling
> input_mt_destroy_slots() from the error path within input_register_device().
>
> Maybe a better option is to update input_mt_init_slots() to use device-managed
> allocation instead?

I think that devm_ is the way to go:

$ git grep input_mt_init_slots | wc -l
82

$ git grep input_mt_destroy_slots | wc -l
6

I'll send a patch for it.

>
>>
>> It should also be called in a .remove function (unless
>> devm_add_action_or_reset is prefered)
>
> I think the remove path is OK, as input_dev_release() handles this for us. In
> case I have misunderstood, please let me know.

Agreed. I missed that.

CJ

\
 
 \ /
  Last update: 2023-09-17 20:00    [W:0.067 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site