From: Alok Barsode Date: Wed, 22 Feb 2012 14:19:13 +0000 (+0200) Subject: technology: Fix technology refcounting X-Git-Tag: 0.79~42 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4605cae51a5cb3e4a402c57aad2cd798a8c70c5;p=platform%2Fupstream%2Fconnman.git technology: Fix technology refcounting __sync_fetch_and_sub() gives the value that had previously been in memory which gives the older refount. technology_find() does not refcount the technology. __connman_technology_update_rfkill() was using technology_get() which was refcounting the technology. Every technology_get() must be matched with a corresponding technology_put() for accurate refcounting. --- diff --git a/src/technology.c b/src/technology.c index 12ed5af..4a0f9f1 100644 --- a/src/technology.c +++ b/src/technology.c @@ -934,7 +934,7 @@ static void technology_put(struct connman_technology *technology) { DBG("technology %p", technology); - if (__sync_fetch_and_sub(&technology->refcount, 1) > 0) + if (__sync_sub_and_fetch(&technology->refcount, 1) > 0) return; reply_scan_pending(technology, -EINTR); @@ -1281,7 +1281,7 @@ int __connman_technology_update_rfkill(unsigned int index, return 0; } - technology = technology_get(type); + technology = technology_find(type); /* If there is no driver for this type, ignore it. */ if (technology == NULL) return -ENXIO;