diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index df8456e885..126b01f867 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -455,7 +455,7 @@ udev_get_driver (GUdevDevice *device, int ifindex) driver = g_udev_device_get_driver (device); if (driver) - return driver; + goto out; /* Try the parent */ parent = g_udev_device_get_parent (device); @@ -470,23 +470,18 @@ udev_get_driver (GUdevDevice *device, int ifindex) if ( (g_strcmp0 (subsys, "ibmebus") == 0) || (subsys == NULL)) { grandparent = g_udev_device_get_parent (parent); - if (grandparent) { + if (grandparent) driver = g_udev_device_get_driver (grandparent); - } } } } - - /* Intern the string so we don't have to worry about memory - * management in NMPlatformLink. - */ - if (driver) - driver = g_intern_string (driver); - g_clear_object (&parent); g_clear_object (&grandparent); - return driver; +out: + /* Intern the string so we don't have to worry about memory + * management in NMPlatformLink. */ + return g_intern_string (driver); } /****************************************************************** diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 3d00ae4ae4..9b1d64e7ff 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -2856,7 +2856,7 @@ nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b) _CMP_FIELD_BOOL (a, b, initialized); _CMP_FIELD_STR_INTERNED (a, b, kind); _CMP_FIELD_STR0 (a, b, udi); - _CMP_FIELD_STR0 (a, b, driver); + _CMP_FIELD_STR_INTERNED (a, b, driver); return 0; } diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 43b9731f5b..8d914c5e3b 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -86,11 +86,17 @@ struct _NMPlatformLink { char name[IFNAMSIZ]; NMLinkType type; - /* rtnl_link_get_type(), IFLA_INFO_KIND */ + /* rtnl_link_get_type(), IFLA_INFO_KIND. */ + /* NMPlatform initializes this field with a static string. */ const char *kind; + /* Beware: NMPlatform initializes this string with an allocated string. + * Handle it properly (i.e. don't keep a reference to it). */ const char *udi; + + /* NMPlatform initializes this field with a static string. */ const char *driver; + gboolean initialized; int master; int parent;