mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-30 22:38:06 +02:00
device: require that device-factories support at least one link-type or setting-type
If a device-factory wouldn't support any link-type or setting-type,
we would not take an additional reference to the @factory instance
(because, the factory is not added to one of the static hash tables).
As such, we would invoke the callback with a factory instance, which
is about to be destroyed immediately afterwards. That would be unusual
for device-plugins, because usually a device-plugin is never destroyed
and essentially leaked at exit.
Just don't get into that situation. All device plugins are internal API,
and they are known to support at least something. Assert for that.
(cherry picked from commit 94200b03fe)
This commit is contained in:
parent
aa27007ff0
commit
1388569fce
1 changed files with 4 additions and 0 deletions
|
|
@ -301,6 +301,10 @@ _add_factory (NMDeviceFactory *factory,
|
|||
|
||||
nm_device_factory_get_supported_types (factory, &link_types, &setting_types);
|
||||
|
||||
g_return_val_if_fail ( (link_types && link_types[0] > NM_LINK_TYPE_UNKNOWN)
|
||||
|| (setting_types && setting_types[0]),
|
||||
FALSE);
|
||||
|
||||
for (i = 0; link_types && link_types[i] > NM_LINK_TYPE_UNKNOWN; i++)
|
||||
g_hash_table_insert (factories_by_link, GUINT_TO_POINTER (link_types[i]), g_object_ref (factory));
|
||||
for (i = 0; setting_types && setting_types[i]; i++) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue