[PATCH] autofs4: atomic var underflow
authorIan Kent <raven@themaw.net>
Mon, 27 Mar 2006 09:14:59 +0000 (01:14 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 27 Mar 2006 16:44:41 +0000 (08:44 -0800)
Fix accidental underflow of the atomic counter.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/autofs4/autofs_i.h
fs/autofs4/waitq.c

index ff6239d57b4b419ab21f8eaff1228d3dc3375e4d..617fd7b37447a326623525b85d64de024b455141 100644 (file)
@@ -85,7 +85,7 @@ struct autofs_wait_queue {
        pid_t tgid;
        /* This is for status reporting upon return */
        int status;
-       atomic_t notified;
+       atomic_t notify;
        atomic_t wait_ctr;
 };
 
index 894d74671bd0ed8b571d70e43c1680f479b391d9..142ab6aa2aa1516e6480d24c0ce3830b19852107 100644 (file)
@@ -263,7 +263,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                wq->tgid = current->tgid;
                wq->status = -EINTR; /* Status return if interrupted */
                atomic_set(&wq->wait_ctr, 2);
-               atomic_set(&wq->notified, 1);
+               atomic_set(&wq->notify, 1);
                mutex_unlock(&sbi->wq_mutex);
        } else {
                atomic_inc(&wq->wait_ctr);
@@ -273,9 +273,11 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
                        (unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
        }
 
-       if (notify != NFY_NONE && atomic_dec_and_test(&wq->notified)) {
+       if (notify != NFY_NONE && atomic_read(&wq->notify)) {
                int type;
 
+               atomic_dec(&wq->notify);
+
                if (sbi->version < 5) {
                        if (notify == NFY_MOUNT)
                                type = autofs_ptype_missing;