Re: [PATCH 1/3] HID: apple: avoid memory leak in apple_report_fixup()
From: Günther Noack
Date: Thu Feb 19 2026 - 10:52:19 EST
On Wed, Feb 18, 2026 at 08:04:52PM +0100, Benjamin Tissoires wrote:
> Ouch. Yeah, sorry. I wrote that code and it seemed I completely paged
> it out. Your code is actually correct (all three) but it would be nice
> to have a longer commit message explaining this above.
>
> The main point of this alloc before calling fixup is because some
> drivers are using a static array as the new report descriptor. So we can
> not free it later on. Working on a known copy allows to handle the kfree
> correctly.
>
> So yes, sorry, returning rdesc+1 in 1/3 and 2/3 is correct, and using a
> devm_kzalloc is too in 3/3.
Ah OK, thanks for the review! I sent you an updated version where I
am trying to express it more clearly in the commit messages.
I also added a commit that documents the expected allocation
properties in hid.h where the .report_fixup() field is defined (feel
free to ignore this one, if it feels like it's too much).
Link to V2:
https://lore.kernel.org/all/20260219154338.786625-2-gnoack@xxxxxxxxxx/
—Günther