Re: [PATCH v2] kref: warn on uninitialized kref

2014-05-19 Thread Peter Zijlstra
On Sat, May 17, 2014 at 05:14:13PM -0400, Mikulas Patocka wrote: > BTW. if we talk about performance - what about replacing: > > if (atomic_dec_and_test(&variable)) { > ... release(object); > } > > with this: > > if (atomic_read(&variable) == 1 || atomic_dec_and_t

Re: [PATCH v2] kref: warn on uninitialized kref

2014-05-18 Thread Bart Van Assche
On 05/17/14 23:14, Mikulas Patocka wrote: > BTW. if we talk about performance - what about replacing: > > if (atomic_dec_and_test(&variable)) { > ... release(object); > } > > with this: > > if (atomic_read(&variable) == 1 || atomic_dec_and_test(&variable)) { >

Re: [PATCH v2] kref: warn on uninitialized kref

2014-05-17 Thread Mikulas Patocka
On Sat, 17 May 2014, Bart Van Assche wrote: > On 05/17/14 14:38, Mikulas Patocka wrote: > > I found a memory leak in iSCSI target that was caused by kref initialized > > to zero (the memory object was allocated with kzalloc, kref_init was not > > called and kref_put_spinlock_irqsave was called w

Re: [PATCH v2] kref: warn on uninitialized kref

2014-05-17 Thread Bart Van Assche
On 05/17/14 14:38, Mikulas Patocka wrote: > I found a memory leak in iSCSI target that was caused by kref initialized > to zero (the memory object was allocated with kzalloc, kref_init was not > called and kref_put_spinlock_irqsave was called which changed "0" to "-1" > and didn't free the object).

[PATCH v2] kref: warn on uninitialized kref

2014-05-17 Thread Mikulas Patocka
I found a memory leak in iSCSI target that was caused by kref initialized to zero (the memory object was allocated with kzalloc, kref_init was not called and kref_put_spinlock_irqsave was called which changed "0" to "-1" and didn't free the object). Similar bugs may exist in other kernel areas, so