Showing error 814

User: Jiri Slaby
Error type: Resource Leak
Error type description: The code omits to put the resource to the system for reuse
File location: lib/kernel_lock.c
Line in file: 46
Project: Linux Kernel
Project version: 2.6.28
Tools: Stanse (1.2)
Entered: 2011-11-07 22:40:13 UTC


Source:

 16 * This spinlock is taken and released recursively by lock_kernel()
 17 * and unlock_kernel().  It is transparently dropped and reacquired
 18 * over schedule().  It is used to protect legacy code that hasn't
 19 * been migrated to a proper locking design yet.
 20 *
 21 * Don't use in new code.
 22 */
 23static  __cacheline_aligned_in_smp DEFINE_SPINLOCK(kernel_flag);
 24
 25
 26/*
 27 * Acquire/release the underlying lock from the scheduler.
 28 *
 29 * This is called with preemption disabled, and should
 30 * return an error value if it cannot get the lock and
 31 * TIF_NEED_RESCHED gets set.
 32 *
 33 * If it successfully gets the lock, it should increment
 34 * the preemption count like any spinlock does.
 35 *
 36 * (This works on UP too - _raw_spin_trylock will never
 37 * return false in that case)
 38 */
 39int __lockfunc __reacquire_kernel_lock(void)
 40{
 41        while (!_raw_spin_trylock(&kernel_flag)) {
 42                if (test_thread_flag(TIF_NEED_RESCHED))
 43                        return -EAGAIN;
 44                cpu_relax();
 45        }
 46        preempt_disable();
 47        return 0;
 48}
 49
 50void __lockfunc __release_kernel_lock(void)
 51{
 52        _raw_spin_unlock(&kernel_flag);
 53        preempt_enable_no_resched();
 54}
 55
 56/*
Show full sources