technology: Decrease blocked refcount when removing a blocked device
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 23 Nov 2010 13:44:26 +0000 (14:44 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 23 Nov 2010 13:53:06 +0000 (14:53 +0100)
Fixes BMC#10330

src/technology.c

index b315e95..98fcf8d 100644 (file)
@@ -689,6 +689,8 @@ int __connman_technology_update_rfkill(unsigned int index,
 int __connman_technology_remove_rfkill(unsigned int index)
 {
        struct connman_technology *technology;
+       struct connman_rfkill *rfkill;
+       connman_bool_t blocked;
 
        DBG("index %u", index);
 
@@ -696,11 +698,18 @@ int __connman_technology_remove_rfkill(unsigned int index)
        if (technology == NULL)
                return -ENXIO;
 
+       rfkill = g_hash_table_lookup(technology->rfkill_list, &index);
+       if (rfkill == NULL)
+               return -ENXIO;
+
+       blocked = (rfkill->softblock || rfkill->hardblock) ? TRUE : FALSE;
+
        g_hash_table_remove(technology->rfkill_list, &index);
 
        g_hash_table_remove(rfkill_table, &index);
 
-       if (g_atomic_int_dec_and_test(&technology->blocked) == TRUE) {
+       if (blocked &&
+               g_atomic_int_dec_and_test(&technology->blocked) == TRUE) {
                technology_blocked(technology, FALSE);
                technology->state = CONNMAN_TECHNOLOGY_STATE_AVAILABLE;
                state_changed(technology);