Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

autofs - Fix sparse warning: context imbalance in autofs4_d_automount() different lock contexts for basic block

Sparse complains:

fs/autofs4/root.c:409:9: sparse: context imbalance in 'autofs4_d_automount' - different lock contexts for basic block

This was introduced by commit f55fb0c24386 ("autofs4 - dont clear
DCACHE_NEED_AUTOMOUNT on rootless mount")

The function autofs4_d_automount can be left with the (&sbi->fs_lock)
held if sbi->version <= 4 and simple_empty(dentry) == false so the
warning seems valid.

--> Add an spin_unlock in this case before we jump to done

Unfortunately compile tested only.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Acked-by: Ian Kent <raven@themaw.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Peter Huewe and committed by
Linus Torvalds
9d8072e7 b0af9cd9

+3 -1
+3 -1
fs/autofs4/root.c
··· 383 383 goto done; 384 384 } 385 385 } else { 386 - if (!simple_empty(dentry)) 386 + if (!simple_empty(dentry)) { 387 + spin_unlock(&sbi->fs_lock); 387 388 goto done; 389 + } 388 390 } 389 391 ino->flags |= AUTOFS_INF_PENDING; 390 392 spin_unlock(&sbi->fs_lock);