Messages in this thread | | | Date | Thu, 27 Apr 2006 13:45:12 +0200 | From | Rogier Wolff <> | Subject | Re: [patch 1/4] kref: warn kref_put() with unreferenced kref |
| |
On Mon, Apr 24, 2006 at 04:33:34PM +0800, Akinobu Mita wrote: > @@ -56,12 +57,13 @@ int kref_put(struct kref *kref, void (*r > * if current count is one, we are the last user and can release object > * right now, avoiding an atomic operation on 'refcount' > */ > - if ((atomic_read(&kref->refcount) == 1) || > - (atomic_dec_and_test(&kref->refcount))) { > - release(kref); > - return 1; > - } > - return 0; > + if (atomic_read(&kref->refcount) == 1) > + atomic_set(&kref->refcount, 0); > + else if (!atomic_dec_and_test(&kref->refcount)) > + return 0;
This is WRONG. The refcount can be incremented (to two) AFTER the atomic_read ==1 and the "atomic_set". The original code seems ok in this respect.
Roger.
-- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 ** *-- BitWizard writes Linux device drivers for any device you may have! --* Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement. Does it sit on the couch all day? Is it unemployed? Please be specific! Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |