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.
(cherry picked from commit 31245cdd62
)
This commit is contained in:
@@ -1210,9 +1210,11 @@ nm_manager_get_device_by_ifindex (NMManager *self, int ifindex)
|
|||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||||
NMDevice *device;
|
NMDevice *device;
|
||||||
|
|
||||||
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
if (ifindex > 0) {
|
||||||
if (nm_device_get_ifindex (device) == ifindex)
|
c_list_for_each_entry (device, &priv->devices_lst_head, devices_lst) {
|
||||||
return device;
|
if (nm_device_get_ifindex (device) == ifindex)
|
||||||
|
return device;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user