* [patch] TTY/n_gsm: potential double lock
@ 2010-05-25 9:37 Dan Carpenter
2010-05-25 12:42 ` Alan Cox
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-05-25 9:37 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: Alan Cox, linux-kernel, kernel-janitors
In gsm_dlci_data_kick() we call gsm_dlci_data_sweep() with the
"gsm->tx_lock" held so we can't lock it again inside
gsm_dlci_data_sweep(). I removed that lock from and added one to
gsmld_write_wakeup() instead. The sweep function is only called from
those two places.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/char/n_gsm.c b/drivers/char/n_gsm.c
index c4161d5..e4089c4 100644
--- a/drivers/char/n_gsm.c
+++ b/drivers/char/n_gsm.c
@@ -904,9 +904,7 @@ static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
int len;
/* Priority ordering: We should do priority with RR of the groups */
int i = 1;
- unsigned long flags;
- spin_lock_irqsave(&gsm->tx_lock, flags);
while (i < NUM_DLCI) {
struct gsm_dlci *dlci;
@@ -927,7 +925,6 @@ static void gsm_dlci_data_sweep(struct gsm_mux *gsm)
if (len = 0)
i++;
}
- spin_unlock_irqrestore(&gsm->tx_lock, flags);
}
/**
@@ -2230,12 +2227,16 @@ static int gsmld_open(struct tty_struct *tty)
static void gsmld_write_wakeup(struct tty_struct *tty)
{
struct gsm_mux *gsm = tty->disc_data;
+ unsigned long flags;
/* Queue poll */
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
gsm_data_kick(gsm);
- if (gsm->tx_bytes < TX_THRESH_LO)
+ if (gsm->tx_bytes < TX_THRESH_LO) {
+ spin_lock_irqsave(&gsm->tx_lock, flags);
gsm_dlci_data_sweep(gsm);
+ spin_unlock_irqrestore(&gsm->tx_lock, flags);
+ }
}
/**
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] TTY/n_gsm: potential double lock
2010-05-25 9:37 [patch] TTY/n_gsm: potential double lock Dan Carpenter
@ 2010-05-25 12:42 ` Alan Cox
0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2010-05-25 12:42 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Greg Kroah-Hartman, linux-kernel, kernel-janitors
On Tue, 25 May 2010 11:37:17 +0200
Dan Carpenter <error27@gmail.com> wrote:
> In gsm_dlci_data_kick() we call gsm_dlci_data_sweep() with the
> "gsm->tx_lock" held so we can't lock it again inside
> gsm_dlci_data_sweep(). I removed that lock from and added one to
> gsmld_write_wakeup() instead. The sweep function is only called from
> those two places.
Well spotted - I'm surprised that escaped as I've been using the code a
fair bit in that exact form. Not immediately obvious that the case
should be that hard to trigger.
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Alan Cox <alan@linux.intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-25 12:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 9:37 [patch] TTY/n_gsm: potential double lock Dan Carpenter
2010-05-25 12:42 ` Alan Cox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).