summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Giudici <fgiudici@redhat.com>2016-04-11 16:00:49 +0200
committerFrancesco Giudici <fgiudici@redhat.com>2016-04-13 12:03:12 +0200
commit5f8ae4e1e5f4f53496d259e3f4be0edcec1bea83 (patch)
tree993264e23f2d0b49d31d6d95ea2903e1696942a0
parenta72dd80a944afcc08538ecee22d00b6a9c069d0d (diff)
downloadNetworkManager-5f8ae4e1e5f4f53496d259e3f4be0edcec1bea83.tar.gz
device: ensure @error always set by nm_device_factory_new_link
https://bugzilla.redhat.com/show_bug.cgi?id=1325631 (backported from commit c5d827057e71e349a02922982323d2e8a85081c8)
-rw-r--r--src/devices/nm-device-factory.c21
-rw-r--r--src/nm-manager.c3
2 files changed, 21 insertions, 3 deletions
diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c
index 1303480857..b8edb9d102 100644
--- a/src/devices/nm-device-factory.c
+++ b/src/devices/nm-device-factory.c
@@ -88,12 +88,17 @@ nm_device_factory_new_link (NMDeviceFactory *factory,
const NMLinkType *link_types = NULL;
const char **setting_types = NULL;
int i;
+ NMDevice *device;
+ gboolean ignore = FALSE;
g_return_val_if_fail (factory != NULL, NULL);
g_return_val_if_fail (plink != NULL, NULL);
/* Ensure the factory can create interfaces for this connection */
nm_device_factory_get_supported_types (factory, &link_types, &setting_types);
+
+ NM_SET_OUT (out_ignore, FALSE);
+
for (i = 0; link_types[i] > NM_LINK_TYPE_UNKNOWN; i++) {
if (plink->type == link_types[i])
break;
@@ -115,7 +120,21 @@ nm_device_factory_new_link (NMDeviceFactory *factory,
return NULL;
}
- return interface->new_link (factory, plink, out_ignore, error);
+ device = interface->new_link (factory, plink, &ignore, error);
+ NM_SET_OUT (out_ignore, ignore);
+
+ if (!device && error && !*error) {
+ if (ignore) {
+ g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
+ "Device factory %s ignores device",
+ G_OBJECT_TYPE_NAME (factory));
+ } else {
+ g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_FAILED,
+ "Device factory %s failed to create device",
+ G_OBJECT_TYPE_NAME (factory));
+ }
+ }
+ return device;
}
NMDevice *
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 082b7ef908..61e3aef78b 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -1936,7 +1936,6 @@ platform_link_added (NMManager *self,
{
NMDeviceFactory *factory;
NMDevice *device = NULL;
- GError *error = NULL;
g_return_if_fail (ifindex > 0);
@@ -1947,13 +1946,13 @@ platform_link_added (NMManager *self,
factory = nm_device_factory_manager_find_factory_for_link_type (plink->type);
if (factory) {
gboolean ignore = FALSE;
+ gs_free_error GError *error = NULL;
device = nm_device_factory_new_link (factory, plink, &ignore, &error);
if (!device) {
if (!ignore) {
nm_log_warn (LOGD_HW, "%s: factory failed to create device: %s",
plink->name, error->message);
- g_clear_error (&error);
}
return;
}