Re: [PATCH 2.6.12-rc4] cpuset exit NULL dereference fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Thu, 26 May 2005, Robin Holt wrote:
> 
> Why not change the atomic into a lock and a refcount.  Grab the lock before
> each increment/decrement of the refcount and only continue with the removal
> code when the refcount reaches 0.

For this, there is a nice 

	atomic_dec_and_lock()

function that is the same as "atomic_dec_and_test()", except it grabs the 
lock if the count decrements to zero.

I'm surprised people haven't picked up on it - it's been around for a
while, the VFS layer uses it for some quite fundamental data structures
(inode and dcache refcounts), and it's even documented in "atomic_ops.txt"

And it's _designed_ for refcountign things like this.

Basic rule of kernel programming: if a globally visible object does not 
have a refcount, IT IS A BUG.

		Linus
-
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]
  Powered by Linux