wifi: merge branch 'fg/nm-1-0_wifi_segfault_rh1325631'

https://bugzilla.redhat.com/show_bug.cgi?id=1325631
This commit is contained in:
Francesco Giudici 2016-04-13 18:51:28 +02:00
commit a5dc355d4d
3 changed files with 33 additions and 3 deletions

View file

@ -111,6 +111,15 @@
/* macro to return strlen() of a compile time string. */
#define STRLEN(str) ( sizeof ("" str) - 1 )
#define NM_SET_OUT(out_val, value) \
G_STMT_START { \
typeof(*(out_val)) *_out_val = (out_val); \
\
if (_out_val) { \
*_out_val = (value); \
} \
} G_STMT_END
/********************************************************/
#define _NM_IN_SET_EVAL_1(op, x, y1) \

View file

@ -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 *

View file

@ -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,16 @@ 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);
} else {
nm_log_dbg (LOGD_HW, "%s: factory failed to create device: %s",
plink->name, error->message);
}
return;
}