diff options
| author | dragonpt <cesar.maximo@gmail.com> | 2015-12-27 19:15:52 +0000 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2016-11-11 02:45:22 +0100 |
| commit | 8d730f510120004a1206c6aa6a2fbd3868b3e4af (patch) | |
| tree | dfe4edcc4286f43b4081969af01c1c9b810f940f /tools/perf/scripts/python | |
| parent | bd5438ab1cf6514e5ced15e3490153ebb33bf28d (diff) | |
tty: Properly fix memleak of alloc_pid
Cylen Yao <cylen.yao@mediatek.com>
bug: 7845126 MT67x2
Memleak is due to unreleased pid->count, which execute in function:
get_pid()(pid->count++) and put_pid()(pid->count--).
The race condition as following:
task[dumpsys] task[adbd]
in disassociate_ctty() in tty_signal_session_leader()
----------------------- -------------------------
tty = get_current_tty();
// tty is not NULL
...
spin_lock_irq(¤t->sighand->siglock);
put_pid(current->signal->tty_old_pgrp);
current->signal->tty_old_pgrp = NULL;
spin_unlock_irq(¤t->sighand->siglock);
spin_lock_irq(&p->sighand->siglock);
...
p->signal->tty = NULL;
...
spin_unlock_irq(&p->sighand->siglock);
tty = get_current_tty();
// tty NULL, goto else branch by accident.
if (tty) {
...
put_pid(tty_session);
put_pid(tty_pgrp);
...
} else {
print msg
}
in task[dumpsys], in disassociate_ctty(), tty is set NULL by task[adbd],
tty_signal_session_leader(), then it goto else branch and lack of
put_pid(), cause memleak.
move spin_unlock(sighand->siglock) after get_current_tty() can avoid
the race and fix the memleak.
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
