[PATCH 1/5] Input: ambakmi - Convert to use devm_*()

From
Leo Yan <hidden>
Date
2017-03-26 15:30:56
Also in
alsa-devel, kvm, linux-input, linux-rtc, lkml
Reply to
Russell King - ARM Linux, 2017-03-26
On Sun, Mar 26, 2017 at 03:50:24PM +0100, Russell King - ARM Linux wrote:
On Sun, Mar 26, 2017 at 10:41:50PM +0800, Leo Yan wrote:
quoted
Convert driver to use devm_*() APIs so rely on driver model core layer
to manage resources. This eliminates error path boilerplate and makes
code neat.

This patch also fixes the memory leakage for 'kmi->io' when remove
module.
No, it is not leaked, in fact, your patch introduces a use-after-free
bug.

kmi->io is of type "struct serio", and this structure has an embedded
"struct device".  The lifetime of any structure containing a "struct
device" is controlled by the lifetime of the struct device.

Once serio_register_port() has been called on it, it is up to the
serio layer to free this structure.

Therefore, your patch creates a bug, and so it gets a NAK.  There is no
resource leakage here.
Thanks for reviewing. Now I understood and please ignore this patch
and patch 0005.

Thanks,
Leo Yan
Thread (15 messages) 15 messages, 5 authors, last reply 2017-04-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help