panda: call libusb_free_device_list before libusb_exit (#22162)

old-commit-hash: a077b8a566c27d3625047c0f165b75906df45cff
This commit is contained in:
Dean Lee
2021-09-08 06:52:34 +08:00
committed by GitHub
parent 9a1fa559ba
commit 5afeb1e0a3
+4 -4
View File
@@ -82,10 +82,10 @@ Panda::Panda(std::string serial) {
return;
fail:
cleanup();
if (dev_list != NULL) {
libusb_free_device_list(dev_list, 1);
}
cleanup();
throw std::runtime_error("Error connecting to panda");
}
@@ -138,12 +138,12 @@ std::vector<std::string> Panda::list() {
}
finish:
if (context) {
libusb_exit(context);
}
if (dev_list != NULL) {
libusb_free_device_list(dev_list, 1);
}
if (context) {
libusb_exit(context);
}
return serials;
}