mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 06:10:14 +01:00
manager: return NULL for invalid ifindex in nm_manager_get_device_by_ifindex()
Internally, the device migth have negative or zero ifindex. When calling nm_manager_get_device_by_ifindex(), the caller wants to find a device with a valid ifindex, hence filter out non-positive values.
This commit is contained in:
parent
aef5110fa6
commit
31245cdd62
1 changed files with 5 additions and 3 deletions
|
|
@ -1210,9 +1210,11 @@ nm_manager_get_device_by_ifindex (NMManager *self, int ifindex)
|
|||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
NMDevice *device;
|
||||
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
if (nm_device_get_ifindex (device) == ifindex)
|
||||
return device;
|
||||
if (ifindex > 0) {
|
||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||
if (nm_device_get_ifindex (device) == ifindex)
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue