Skip to content

Commit

Permalink
Fix udev reference leak in LinuxNetworkIF (#1569)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbwiddis committed Mar 14, 2021
1 parent 216a735 commit 6500d82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* [#1562](https://github.com/oshi/oshi/pull/1562): Fix missing space in WMI process query - [@dbwiddis](https://github.com/dbwiddis).
* [#1566](https://github.com/oshi/oshi/pull/1566): Handle new WinAPI Logical Processor Information types - [@dbwiddis](https://github.com/dbwiddis).
* [#1567](https://github.com/oshi/oshi/pull/1567): Handle empty process performance registry query - [@dbwiddis](https://github.com/dbwiddis).
* [#1569](https://github.com/oshi/oshi/pull/1569): Fix udev reference leak in LinuxNetworkIF - [@dbwiddis](https://github.com/dbwiddis).

# 5.6.0 (2021-03-01)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,25 @@ public LinuxNetworkIF(NetworkInterface netint) throws InstantiationException {
private static String queryIfModel(NetworkInterface netint) {
String name = netint.getName();
UdevContext udev = Udev.INSTANCE.udev_new();
UdevDevice device = udev.deviceNewFromSyspath("/sys/class/net/" + name);
if (device != null) {
if (udev != null) {
try {
String devVendor = device.getPropertyValue("ID_VENDOR_FROM_DATABASE");
String devModel = device.getPropertyValue("ID_MODEL_FROM_DATABASE");
if (!Util.isBlank(devModel)) {
if (!Util.isBlank(devVendor)) {
return devVendor + " " + devModel;
UdevDevice device = udev.deviceNewFromSyspath("/sys/class/net/" + name);
if (device != null) {
try {
String devVendor = device.getPropertyValue("ID_VENDOR_FROM_DATABASE");
String devModel = device.getPropertyValue("ID_MODEL_FROM_DATABASE");
if (!Util.isBlank(devModel)) {
if (!Util.isBlank(devVendor)) {
return devVendor + " " + devModel;
}
return devModel;
}
} finally {
device.unref();
}
return devModel;
}
} finally {
device.unref();
udev.unref();
}
}
return name;
Expand Down

0 comments on commit 6500d82

Please sign in to comment.