kernel: locking: add releases(lock) annotation
PATCH 1/1 kernel: locking: add releases(lock) annotation
Add releases(lock) annotation to remove issue detected by sparse tool.
warning: context imbalance in xxxxxxx() - unexpected unlock
--- kernel/locking/spinlock.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/locking/spinlock.c +5 -0
@@ -187,6 +187,7 @@ EXPORT_SYMBOL(_raw_spin_unlock);#ifndef CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE void __lockfunc _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags) +__releases (lock) {__raw_spin_unlock_irqrestore (lock, flags); }
@@ -203,6 +204,7 @@ EXPORT_SYMBOL(_raw_spin_unlock_irq);#ifndef CONFIG_INLINE_SPIN_UNLOCK_BH void __lockfunc _raw_spin_unlock_bh(raw_spinlock_t *lock) +__releases (lock) {__raw_spin_unlock_bh (lock); }
@@ -275,6 +277,7 @@ EXPORT_SYMBOL(_raw_read_unlock_irq);#ifndef CONFIG_INLINE_READ_UNLOCK_BH void __lockfunc _raw_read_unlock_bh(rwlock_t *lock) +__releases (lock) {__raw_read_unlock_bh (lock); }
@@ -331,6 +334,7 @@ EXPORT_SYMBOL(_raw_write_unlock);#ifndef CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE void __lockfunc _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags) +__releases (lock) {__raw_write_unlock_irqrestore (lock, flags); }
@@ -347,6 +351,7 @@ EXPORT_SYMBOL(_raw_write_unlock_irq);#ifndef CONFIG_INLINE_WRITE_UNLOCK_BH void __lockfunc _raw_write_unlock_bh(rwlock_t *lock) +__releases (lock) {__raw_write_unlock_bh (lock); }
Signature · 1 line
2.23.0
Peter Zijlstra
maintainerQuoted 4 lines · Jules Irenge
Add releases(lock) annotation to remove issue detected by sparse tool.
warning: context imbalance inxxxxxxx()- unexpected unlockSigned-off-by Jules Irenge <[email protected]>
So, personally I detest these sparse things.
But I'm also confused, as that function already has the annotation, see spinlock_api_smp.h. In order for sparse to see these annotations at the usage size, they need to be on the declaration, not the definition.
Quoted 4 lines · Peter Zijlstra
Quoted 3 lines · Jules Irenge
Add releases(lock) annotation to remove issue detected by sparse tool.
warning: context imbalance inxxxxxxx()- unexpected unlock
Quoted 8 lines
Quoted 1 line
Signed-off-by Jules Irenge <[email protected]>So, personally I detest these sparse things.
But I'm also confused, as that function already has the annotation, see
spinlock_api_smp.h. In order for sparse to see these annotations at the usage size, they need to be on the declaration, not the definition.
Yes, I completely agree with you, but acording to my short experience with Sparse, the warning at function definition will always be there despite the annotation being at the function declaration.
The annotation at declaration help fix the warning when the anotated function is called within another function, this function can be elsewhere. It fixes the warning at the function within which the annotated function has been called.
Please correct me if I am wrong.
Kind regards,
Jules