Patch submission

Vincent Perrier perrier.vincent0210 at gmail.com
Fri Jul 12 14:02:07 UTC 2019


Fix memory leak in librtlsdr.

The problem came up when using rtlsdr_open() twice with the same index.
The variable dev->devh is never cleaned if libusb_claim_interface() fails.
This causes a leak if the device is already claimed by another handle.
rtlsdr_close() did not free that space since the returned handle is invalid
if libusb_claim_interface fails

Here is the patch file in text format. (it is also joined to this email).

~~~~
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index a71609b..89ec903 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1520,10 +1520,6 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t
index)
        r = libusb_claim_interface(dev->devh, 0);
        if (r < 0) {
                fprintf(stderr, "usb_claim_interface error %d\n", r);
-               if (dev)
-               {
-               libusb_close(dev->devh);
-               }
                goto err;
        }
~~~~

-Vincent Perrier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/osmocom-sdr/attachments/20190712/22849f18/attachment.html>


More information about the osmocom-sdr mailing list