summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/syscons/scmouse.c17
-rw-r--r--sys/dev/syscons/syscons.c22
2 files changed, 28 insertions, 11 deletions
diff --git a/sys/dev/syscons/scmouse.c b/sys/dev/syscons/scmouse.c
index fab57da..ccfc2f2 100644
--- a/sys/dev/syscons/scmouse.c
+++ b/sys/dev/syscons/scmouse.c
@@ -604,6 +604,7 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
mouse_info_t buf;
scr_stat *cur_scp;
scr_stat *scp;
+ struct proc *p1;
int s;
int f;
@@ -755,15 +756,15 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
cur_scp->status &= ~MOUSE_HIDDEN;
- if (cur_scp->mouse_signal) {
+ if (cur_scp->mouse_signal && cur_scp->mouse_proc) {
/* has controlling process died? */
- if (cur_scp->mouse_proc &&
- (cur_scp->mouse_proc != pfind(cur_scp->mouse_pid))){
+ if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))) {
cur_scp->mouse_signal = 0;
cur_scp->mouse_proc = NULL;
cur_scp->mouse_pid = 0;
+ if (p1)
+ PROC_UNLOCK(p1);
} else {
- PROC_LOCK(cur_scp->mouse_proc);
psignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
PROC_UNLOCK(cur_scp->mouse_proc);
break;
@@ -811,14 +812,14 @@ sc_mouse_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
cur_scp->status &= ~MOUSE_HIDDEN;
- if (cur_scp->mouse_signal) {
- if (cur_scp->mouse_proc &&
- (cur_scp->mouse_proc != pfind(cur_scp->mouse_pid))){
+ if (cur_scp->mouse_signal && cur_scp->mouse_proc) {
+ if (cur_scp->mouse_proc != (p1 = pfind(cur_scp->mouse_pid))){
cur_scp->mouse_signal = 0;
cur_scp->mouse_proc = NULL;
cur_scp->mouse_pid = 0;
+ if (p1)
+ PROC_UNLOCK(p1);
} else {
- PROC_LOCK(cur_scp->mouse_proc);
psignal(cur_scp->mouse_proc, cur_scp->mouse_signal);
PROC_UNLOCK(cur_scp->mouse_proc);
break;
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index 6d08400..2601c4e 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -839,14 +839,20 @@ scioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
case VT_SETMODE: /* set screen switcher mode */
{
struct vt_mode *mode;
+ struct proc *p1;
mode = (struct vt_mode *)data;
DPRINTF(5, ("sc%d: VT_SETMODE ", sc->unit));
if (scp->smode.mode == VT_PROCESS) {
- if (scp->proc == pfind(scp->pid) && scp->proc != p) {
+ p1 = pfind(scp->pid);
+ if (scp->proc == p1 && scp->proc != p) {
+ if (p1)
+ PROC_UNLOCK(p1);
DPRINTF(5, ("error EPERM\n"));
return EPERM;
}
+ if (p1)
+ PROC_UNLOCK(p1);
}
s = spltty();
if (mode->mode == VT_AUTO) {
@@ -2067,6 +2073,7 @@ int
sc_switch_scr(sc_softc_t *sc, u_int next_scr)
{
struct tty *tp;
+ struct proc *p;
int s;
DPRINTF(5, ("sc0: sc_switch_scr() %d ", next_scr + 1));
@@ -2086,7 +2093,10 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
if (sc->switch_in_progress
&& (sc->cur_scp->smode.mode == VT_PROCESS)
&& sc->cur_scp->proc) {
- if (sc->cur_scp->proc != pfind(sc->cur_scp->pid)) {
+ p = pfind(sc->cur_scp->pid);
+ if (sc->cur_scp->proc != p) {
+ if (p)
+ PROC_UNLOCK(p);
/*
* The controlling process has died!!. Do some clean up.
* NOTE:`cur_scp->proc' and `cur_scp->smode.mode'
@@ -2119,6 +2129,8 @@ sc_switch_scr(sc_softc_t *sc, u_int next_scr)
DPRINTF(5, ("waiting nothing, "));
}
} else {
+ if (p)
+ PROC_UNLOCK(p);
/*
* The controlling process is alive, but not responding...
* It is either buggy or it may be just taking time.
@@ -2283,8 +2295,12 @@ do_switch_scr(sc_softc_t *sc, int s)
static int
vt_proc_alive(scr_stat *scp)
{
+ struct proc *p;
+
if (scp->proc) {
- if (scp->proc == pfind(scp->pid))
+ if ((p = pfind(scp->pid)) != NULL)
+ PROC_UNLOCK(p);
+ if (scp->proc == p)
return TRUE;
scp->proc = NULL;
scp->smode.mode = VT_AUTO;
OpenPOWER on IntegriCloud