summaryrefslogtreecommitdiff
path: root/src/devices/wifi/nm-wifi-factory.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-01-06 21:54:23 +0100
committerThomas Haller <thaller@redhat.com>2016-01-06 22:34:29 +0100
commitccd2ec7b343e1078c8b5d0cd3ee9d8cfd46ddd3f (patch)
tree75017df3e53268c534647e751e2d119740d0b0d3 /src/devices/wifi/nm-wifi-factory.c
parent75131ed65411239851ea1dfc3a2fcc40103dbe6d (diff)
wifi: don't fail construction of NMDeviceWifi in constructor
We cannot abort the construction of a GLib object instance like we did for NMDeviceWifi and NMDeviceOlpcMesh when nm_platform_wifi_get_capabilities() failed. Instead, check the capabilities first (in the factory method) and only create the object instance when the device can be handled. https://bugzilla.gnome.org/show_bug.cgi?id=760154 (cherry picked from commit 044de4cea2c82d289033e75f1e12c7d346dc5537)
Diffstat (limited to 'src/devices/wifi/nm-wifi-factory.c')
-rw-r--r--src/devices/wifi/nm-wifi-factory.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/devices/wifi/nm-wifi-factory.c b/src/devices/wifi/nm-wifi-factory.c
index c4b4042e70..3e31ddf412 100644
--- a/src/devices/wifi/nm-wifi-factory.c
+++ b/src/devices/wifi/nm-wifi-factory.c
@@ -29,6 +29,8 @@
#include "nm-device-olpc-mesh.h"
#include "nm-settings-connection.h"
#include "nm-platform.h"
+#include "nm-macros-internal.h"
+#include "nm-logging.h"
#define NM_TYPE_WIFI_FACTORY (nm_wifi_factory_get_type ())
#define NM_WIFI_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_WIFI_FACTORY, NMWifiFactory))
@@ -61,11 +63,22 @@ nm_device_factory_create (GError **error)
static NMDevice *
new_link (NMDeviceFactory *factory, NMPlatformLink *plink, gboolean *out_ignore, GError **error)
{
+ NMDeviceWifiCapabilities capabilities;
+
+ g_return_val_if_fail (plink != NULL, NULL);
+ g_return_val_if_fail (NM_IN_SET (plink->type, NM_LINK_TYPE_WIFI, NM_LINK_TYPE_OLPC_MESH), NULL);
+
+ if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET,
+ plink->ifindex,
+ &capabilities)) {
+ nm_log_warn (LOGD_HW | LOGD_WIFI, "(%s) failed to initialize Wi-Fi driver for ifindex %d", plink->name, plink->ifindex);
+ return NULL;
+ }
+
if (plink->type == NM_LINK_TYPE_WIFI)
- return nm_device_wifi_new (plink);
- else if (plink->type == NM_LINK_TYPE_OLPC_MESH)
+ return nm_device_wifi_new (plink, capabilities);
+ else
return nm_device_olpc_mesh_new (plink);
- g_assert_not_reached ();
}
NM_DEVICE_FACTORY_DECLARE_TYPES (