n_gsm.c: add tx_lock in gsm_send
authorxiaojin <jin.xiao@intel.com>
Wed, 19 Dec 2012 03:53:43 +0000 (11:53 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jan 2013 05:54:41 +0000 (21:54 -0800)
All the call to gsm->output should be in the tx_lock,
that could avoid potential race from MUX level. But
we have no tx_lock in gsm_send.

This patch is to add tx_lock in gsm_send.

Signed-off-by: xiaojin <jin.xiao@intel.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c

index dcc0430a49c8d082e0c10f97a7a68a02d65f3b18..4572117988f8738ecb2979865647cee58de8f21c 100644 (file)
@@ -573,6 +573,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
        int len;
        u8 cbuf[10];
        u8 ibuf[3];
+       unsigned long flags;
 
        switch (gsm->encoding) {
        case 0:
@@ -602,7 +603,9 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
                WARN_ON(1);
                return;
        }
+       spin_lock_irqsave(&gsm->tx_lock, flags);
        gsm->output(gsm, cbuf, len);
+       spin_unlock_irqrestore(&gsm->tx_lock, flags);
        gsm_print_packet("-->", addr, cr, control, NULL, 0);
 }