Skip to content

Commit

Permalink
HID: core: fix memory leak on probe
Browse files Browse the repository at this point in the history
The dynamically allocted collection stack does not get freed in
all situations. Make sure to also free the collection stack when
using the parser in hid_open_report().

Fixes: 08a8a7c ("HID: core: do not upper bound the collection stack")
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Stefan Agner authored and Jiri Kosina committed Aug 28, 2018
1 parent e38c0ac commit b2dd9f2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ int hid_open_report(struct hid_device *device)
hid_err(device, "unbalanced delimiter at end of report description\n");
goto err;
}
kfree(parser->collection_stack);
vfree(parser);
device->status |= HID_STAT_PARSED;
return 0;
Expand All @@ -1047,6 +1048,7 @@ int hid_open_report(struct hid_device *device)

hid_err(device, "item fetching failed at offset %d\n", (int)(end - start));
err:
kfree(parser->collection_stack);
vfree(parser);
hid_close_report(device);
return ret;
Expand Down

0 comments on commit b2dd9f2

Please sign in to comment.