Skip to contentSkip to conversation

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

PATCH New Ian Kent 1 participant 2 messages Mar 1, 2013

Subsystems (2)
lore
Share & tools
lore

Ian Kent

author maintainer
#0 lore raw

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

From: Peter Huewe <[email protected]>

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
f55fb0c243 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.

---
 fs/autofs4/root.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/autofs4/root.c +3 -1
index 230bd2a..9bd1625 100644
@@ -383,8 +383,10 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
 				goto done;
 			}
 		} else {
-			if (!simple_empty(dentry))
+			if (!simple_empty(dentry)) {
+				spin_unlock(&sbi->fs_lock);
 				goto done;
+			}
 		}
 		ino->flags |= AUTOFS_INF_PENDING;
 		spin_unlock(&sbi->fs_lock);
author maintainer
#1 lore raw

PATCH 2/2 autofs4 - autofs4_catatonic_mode(): remove redundant null check on kfree()

From: Tim Gardner <[email protected]>

smatch analysis:

fs/autofs4/waitq.c:46 autofs4_catatonic_mode() info: redundant null
check on wq->name.name calling kfree()

---
 fs/autofs4/waitq.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
fs/autofs4/waitq.c +2 -4
index 03bc1d3..3db70da 100644
@@ -42,10 +42,8 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
 	while (wq) {
 		nwq = wq->next;
 		wq->status = -ENOENT; /* Magic is gone - report failure */
-		if (wq->name.name) {
-			kfree(wq->name.name);
-			wq->name.name = NULL;
-		}
+		kfree(wq->name.name);
+		wq->name.name = NULL;
 		wq->wait_ctr--;
 		wake_up_interruptible(&wq->queue);
 		wq = nwq;