Skip to content

Commit 239c151

Browse files
gnoackBenjamin Tissoires
authored andcommitted
HID: apple: avoid memory leak in apple_report_fixup()
The apple_report_fixup() function was returning a newly kmemdup()-allocated buffer, but never freeing it. The caller of report_fixup() does not take ownership of the returned pointer, but it *is* permitted to return a sub-portion of the input rdesc, whose lifetime is managed by the caller. Assisted-by: Gemini-CLI:Google Gemini 3 Signed-off-by: Günther Noack <gnoack@google.com> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
1 parent 6b3e458 commit 239c151

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/hid/hid-apple.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,7 @@ static const __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc,
686686
hid_info(hdev,
687687
"fixing up Magic Keyboard battery report descriptor\n");
688688
*rsize = *rsize - 1;
689-
rdesc = kmemdup(rdesc + 1, *rsize, GFP_KERNEL);
690-
if (!rdesc)
691-
return NULL;
689+
rdesc = rdesc + 1;
692690

693691
rdesc[0] = 0x05;
694692
rdesc[1] = 0x01;

0 commit comments

Comments
 (0)