Browse Source

dbus: Do not deinitialize new D-Bus API if it is not initialized

This fixes a crash on error path when D-Bus initialization fails.
Jouni Malinen 15 years ago
parent
commit
26e054ce6b
2 changed files with 5 additions and 0 deletions
  1. 1 0
      wpa_supplicant/dbus/dbus_common_i.h
  2. 4 0
      wpa_supplicant/dbus/dbus_new.c

+ 1 - 0
wpa_supplicant/dbus/dbus_common_i.h

@@ -24,6 +24,7 @@ struct wpas_dbus_priv {
 	int should_dispatch;
 	struct wpa_global *global;
 	u32 next_objid;
+	int dbus_new_initialized;
 };
 
 #endif /* DBUS_COMMON_I_H */

+ 4 - 0
wpa_supplicant/dbus/dbus_new.c

@@ -1070,6 +1070,8 @@ int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
 				       obj_desc);
 	if (ret < 0)
 		free_dbus_object_desc(obj_desc);
+	else
+		priv->dbus_new_initialized = 1;
 
 	return ret;
 }
@@ -1085,6 +1087,8 @@ int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv)
  */
 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface)
 {
+	if (!iface->dbus_new_initialized)
+		return;
 	wpa_printf(MSG_DEBUG, "dbus: Unregister D-Bus object '%s'",
 		   WPAS_DBUS_NEW_PATH);
 	dbus_connection_unregister_object_path(iface->con,