Skip to content

Commit

Permalink
Merge pull request networkupstools#2114 from jimklimov/busport-deref
Browse files Browse the repository at this point in the history
drivers/libusb1.c: nut_libusb_open(): do not keep Bus/Device/BusPort…
  • Loading branch information
jimklimov authored Oct 17, 2023
2 parents 9e7452c + 43552f9 commit 330a00e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/libusb1.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ static int nut_libusb_open(libusb_device_handle **udevp,
} else {
upsdebugx(1, "%s: invalid libusb bus number %i",
__func__, bus_num);
free(curDevice->Bus);
curDevice->Bus = NULL;
}

device_addr = libusb_get_device_address(device);
Expand All @@ -290,6 +292,8 @@ static int nut_libusb_open(libusb_device_handle **udevp,
} else {
upsdebugx(1, "%s: invalid libusb device address %" PRIu8,
__func__, device_addr);
free(curDevice->Device);
curDevice->Device = NULL;
}
}

Expand All @@ -305,6 +309,8 @@ static int nut_libusb_open(libusb_device_handle **udevp,
} else {
upsdebugx(1, "%s: invalid libusb bus number %i",
__func__, bus_port);
free(curDevice->BusPort);
curDevice->BusPort = NULL;
}
#endif

Expand Down

0 comments on commit 330a00e

Please sign in to comment.