Skip to content

Commit

Permalink
get rid of the second argument of acct_kill()
Browse files Browse the repository at this point in the history
Replace the old ns->bacct only with NULL and only if it still points
to acct.  And assign the new value to it *before* calling acct_kill()
in acct_on().  That way we don't need to pass the new acct to acct_kill().

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jan 26, 2015
1 parent 34cece2 commit 3b994d9
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions kernel/acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ static void close_work(struct work_struct *work)
complete(&acct->done);
}

static void acct_kill(struct bsd_acct_struct *acct,
struct bsd_acct_struct *new)
static void acct_kill(struct bsd_acct_struct *acct)
{
if (acct) {
struct pid_namespace *ns = acct->ns;
Expand All @@ -179,7 +178,7 @@ static void acct_kill(struct bsd_acct_struct *acct,
schedule_work(&acct->work);
wait_for_completion(&acct->done);
pin_remove(&acct->pin);
ns->bacct = new;
cmpxchg(&ns->bacct, acct, NULL);
acct->ns = NULL;
atomic_long_dec(&acct->count);
mutex_unlock(&acct->lock);
Expand All @@ -203,7 +202,7 @@ static void acct_pin_kill(struct fs_pin *pin)
acct_put(acct);
acct = NULL;
}
acct_kill(acct, NULL);
acct_kill(acct);
}

static int acct_on(struct filename *pathname)
Expand Down Expand Up @@ -262,10 +261,8 @@ static int acct_on(struct filename *pathname)
pin_insert(&acct->pin, mnt);

old = acct_get(ns);
if (old)
acct_kill(old, acct);
else
ns->bacct = acct;
ns->bacct = acct;
acct_kill(old);
mutex_unlock(&acct->lock);
mnt_drop_write(mnt);
mntput(mnt);
Expand Down Expand Up @@ -302,15 +299,15 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
mutex_unlock(&acct_on_mutex);
putname(tmp);
} else {
acct_kill(acct_get(task_active_pid_ns(current)), NULL);
acct_kill(acct_get(task_active_pid_ns(current)));
}

return error;
}

void acct_exit_ns(struct pid_namespace *ns)
{
acct_kill(acct_get(ns), NULL);
acct_kill(acct_get(ns));
}

/*
Expand Down

0 comments on commit 3b994d9

Please sign in to comment.