Commit d45eed44 authored by Thomas Haller's avatar Thomas Haller

core: avoid calling platform code with invalid ifindex

Since commit 945c904f "platform: assert against valid ifindex and
remove duplicate assertions", it is no longer allowed to call certain
platform functions with invalid ifindex.

These trigger now an assertion. Note that the assertion is merely a
g_return_val_if_fail(), hence in non-debug mode, this does not lead to
a crash.

Fixes: 945c904f
parent 5fb80012
Pipeline #10975 failed with stages
in 0 seconds
......@@ -65,7 +65,7 @@ struct _NMAcdManager {
char _sbuf[64]; \
\
nm_log ((level), _NMLOG_DOMAIN, \
self ? nm_platform_link_get_name (NM_PLATFORM_GET, self->ifindex) : "", \
self && self->ifindex > 0 ? nm_platform_link_get_name (NM_PLATFORM_GET, self->ifindex) : NULL, \
NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
......
......@@ -4846,7 +4846,8 @@ nm_device_master_release_slaves (NMDevice *self)
if (priv->state == NM_DEVICE_STATE_FAILED)
reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED;
if (!nm_platform_link_get (nm_device_get_platform (self), priv->ifindex))
if ( priv->ifindex <= 0
|| !nm_platform_link_get (nm_device_get_platform (self), priv->ifindex))
configure = FALSE;
c_list_for_each_safe (iter, safe, &priv->slaves) {
......
......@@ -128,7 +128,7 @@ typedef struct {
int _ifindex = (self) ? NM_LLDP_LISTENER_GET_PRIVATE (self)->ifindex : 0; \
\
_nm_log (_level, _NMLOG_DOMAIN, 0, \
nm_platform_link_get_name (NM_PLATFORM_GET, _ifindex), \
_ifindex > 0 ? nm_platform_link_get_name (NM_PLATFORM_GET, _ifindex) : NULL, \
NULL, \
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
_NMLOG_PREFIX_NAME, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment