Summary: | Memory leak in lib: core.c | ||
---|---|---|---|
Product: | libfprint | Reporter: | Mark Harfouche <mark.harfouche> |
Component: | libfprint | Assignee: | libfprint-bugs |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | medium | CC: | bugzilla |
Version: | unspecified | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: |
memory patch leka
Memory leak patch in lib Memory leak patch in lib lib: Fix memory leak patch in device discovery examples: Fix memory leaked by device discovery |
Description
Mark Harfouche
2018-03-10 09:14:40 UTC
Note, these changes are included in #99462 https://bugs.freedesktop.org/show_bug.cgi?id=99462 So if you end up merging 99462 (which I think you should), then this isn't necessary. Comment on attachment 137959 [details] [review] memory patch leka Review of attachment 137959 [details] [review]: ----------------------------------------------------------------- > memory leak Please prefix with "lib: " and explain where the memory leak happens, and what is being leaked. ::: libfprint/core.c @@ +564,4 @@ > struct fp_dscv_dev *ddev = discover_dev(udev); > if (!ddev) > continue; > + libusb_ref_device(udev); Please fix the indentation to match the existing one. Created attachment 137968 [details] [review] Memory leak patch in lib Fixed the indentation to follow the coding style Comment on attachment 137968 [details] [review] Memory leak patch in lib Incomplete patch Created attachment 137969 [details] [review] Memory leak patch in lib the library needs to call libusb_free_device_list(devs, 1); after libusb_get_device_list To do so safely, I think you have to increment the reference to the device you want to use first, then just decrement the reference too the whole list. In finding this bug, I also found a small bug in `img_capture` but that one isn't as important since it isn't part of the library. Created attachment 137986 [details] [review] lib: Fix memory leak patch in device discovery libusb_free_device_list() needs to be called on the list of USB devices obtained through libusb_get_device_list() or the list and its elements will be leaked. Created attachment 137988 [details] [review] examples: Fix memory leaked by device discovery Comment on attachment 137969 [details] [review] Memory leak patch in lib In the future, please try to provide git-formatted patches, and remove white space changes using "git checkout -p" before committing. The patches should also be split into individual cohesive commits as much as possible. I've done all this for the 2 changes you provided. Attachment 137986 [details] pushed as 58ba9b0 - lib: Fix memory leak patch in device discovery Attachment 137988 [details] pushed as 7ff667f - examples: Fix memory leaked by device discovery |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.