Fix not deleting stored keys when a new one is created

When a new link key is created but it doesn't match any criteria to be
stored any previouly one should be removed from filesystem.
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index cf284ab..7498ed6 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -741,6 +741,13 @@
 	/* Clear any previous debug key */
 	device_set_debug_key(device, NULL);
 
+	/* If this is not the first link key set a flag so a subsequent auth
+	 * complete event doesn't trigger SDP and remove any stored key */
+	if (old_key_type != 0xff) {
+		device_set_renewed_key(device, TRUE);
+		device_remove_bonding(device);
+	}
+
 	/* Store the link key only in runtime memory if it's a debug
 	 * key, else store the link key persistently if one of the
 	 * following is true:
@@ -775,11 +782,6 @@
 	} else
 		temporary = TRUE;
 
-	/* If this is not the first link key set a flag so a subsequent auth
-	 * complete event doesn't trigger SDP */
-	if (old_key_type != 0xff)
-		device_set_renewed_key(device, TRUE);
-
 	if (!device_is_connected(device))
 		device_set_secmode3_conn(device, TRUE);
 	else if (!bonding && old_key_type == 0xff)
diff --git a/src/device.c b/src/device.c
index f7d2c52..9d50ad9 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1127,7 +1127,7 @@
 	strncpy(name, device->name, len);
 }
 
-static void device_remove_bonding(struct btd_device *device)
+void device_remove_bonding(struct btd_device *device)
 {
 	char filename[PATH_MAX + 1];
 	char srcaddr[18], dstaddr[18];
diff --git a/src/device.h b/src/device.h
index d43d29f..752dad3 100644
--- a/src/device.h
+++ b/src/device.h
@@ -67,7 +67,7 @@
 DBusMessage *device_create_bonding(struct btd_device *device,
 				DBusConnection *conn, DBusMessage *msg,
 				const char *agent_path, uint8_t capability);
-void device_remove_bondind(struct btd_device *device, DBusConnection *connection);
+void device_remove_bonding(struct btd_device *device);
 void device_bonding_complete(struct btd_device *device, uint8_t status);
 void device_simple_pairing_complete(struct btd_device *device, uint8_t status);
 gboolean device_is_creating(struct btd_device *device, const char *sender);