Re: [PATCH 2/2] Input: add Himax HX852x(ES) touchscreen driver
From: Christophe JAILLET <hidden>
Date: 2023-09-17 17:59:46
Also in:
linux-devicetree, lkml
From: Christophe JAILLET <hidden>
Date: 2023-09-17 17:59:46
Also in:
linux-devicetree, lkml
Le 17/09/2023 à 18:37, Jeff LaBundy a écrit :
quoted
quoted
+ 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.
quoted
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