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.
--
** [email protected] ** 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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]