Skip to content

Commit

Permalink
Better (not racy fix) from Paul Goyette.
Browse files Browse the repository at this point in the history
  • Loading branch information
christos committed Aug 17, 2012
1 parent 6a3a84d commit d3746d5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions sys/kern/tty.c
@@ -1,4 +1,4 @@
/* $NetBSD: tty.c,v 1.252 2012/08/17 16:14:31 christos Exp $ */
/* $NetBSD: tty.c,v 1.253 2012/08/17 16:21:19 christos Exp $ */

/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -63,7 +63,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.252 2012/08/17 16:14:31 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.253 2012/08/17 16:21:19 christos Exp $");

#include <sys/param.h>
#include <sys/systm.h>
Expand Down Expand Up @@ -230,15 +230,20 @@ tty_set_qsize(struct tty *tp, int newsize)
struct clist rawq, canq, outq;
struct clist orawq, ocanq, ooutq;

if (tp->t_outq.c_cc != 0)
return EBUSY;

clalloc(&rawq, newsize, 1);
clalloc(&canq, newsize, 1);
clalloc(&outq, newsize, 0);

mutex_spin_enter(&tty_lock);

if (tp->t_outq.c_cc != 0) {
mutex_spin_exit(&tty_lock);
clfree(&rawq);
clfree(&canq);
clfree(&outq);
return EBUSY;
}

orawq = tp->t_rawq;
ocanq = tp->t_canq;
ooutq = tp->t_outq;
Expand Down

0 comments on commit d3746d5

Please sign in to comment.