Skip to content

Commit 91e8c6e

Browse files
gnoackBenjamin Tissoires
authored andcommitted
HID: magicmouse: avoid memory leak in magicmouse_report_fixup()
The magicmouse_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 239c151 commit 91e8c6e

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/hid/hid-magicmouse.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,7 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
994994
hid_info(hdev,
995995
"fixing up magicmouse battery report descriptor\n");
996996
*rsize = *rsize - 1;
997-
rdesc = kmemdup(rdesc + 1, *rsize, GFP_KERNEL);
998-
if (!rdesc)
999-
return NULL;
997+
rdesc = rdesc + 1;
1000998

1001999
rdesc[0] = 0x05;
10021000
rdesc[1] = 0x01;

0 commit comments

Comments
 (0)