Commit 3e7b1919 authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

[PATCH] autofs4: atomic var underflow

Fix accidental underflow of the atomic counter.
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 871f9434
...@@ -85,7 +85,7 @@ struct autofs_wait_queue { ...@@ -85,7 +85,7 @@ struct autofs_wait_queue {
pid_t tgid; pid_t tgid;
/* This is for status reporting upon return */ /* This is for status reporting upon return */
int status; int status;
atomic_t notified; atomic_t notify;
atomic_t wait_ctr; atomic_t wait_ctr;
}; };
......
...@@ -263,7 +263,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry, ...@@ -263,7 +263,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
wq->tgid = current->tgid; wq->tgid = current->tgid;
wq->status = -EINTR; /* Status return if interrupted */ wq->status = -EINTR; /* Status return if interrupted */
atomic_set(&wq->wait_ctr, 2); atomic_set(&wq->wait_ctr, 2);
atomic_set(&wq->notified, 1); atomic_set(&wq->notify, 1);
mutex_unlock(&sbi->wq_mutex); mutex_unlock(&sbi->wq_mutex);
} else { } else {
atomic_inc(&wq->wait_ctr); atomic_inc(&wq->wait_ctr);
...@@ -273,9 +273,11 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry, ...@@ -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); (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; int type;
atomic_dec(&wq->notify);
if (sbi->version < 5) { if (sbi->version < 5) {
if (notify == NFY_MOUNT) if (notify == NFY_MOUNT)
type = autofs_ptype_missing; type = autofs_ptype_missing;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment