]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
n_gsm: added interlocking for gsm_data_lock for certain code paths
authorRuss Gorby <russ.gorby@intel.com>
Mon, 13 Aug 2012 12:44:40 +0000 (13:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Oct 2012 15:35:55 +0000 (08:35 -0700)
commit 5e44708f75b0f8712da715d6babb0c21089b2317 upstream.

There were some locking holes in the management of the MUX's
message queue for 2 code paths:
1) gsmld_write_wakeup
2) receipt of CMD_FCON flow-control message
In both cases gsm_data_kick is called w/o locking so it can collide
with other other instances of gsm_data_kick (pulling messages tx_tail)
or potentially other instances of __gsm_data_queu (adding messages to tx_head)

Changed to take the tx_lock in these 2 cases

Signed-off-by: Russ Gorby <russ.gorby@intel.com>
Tested-by: Yin, Fengwei <fengwei.yin@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c

index 1720055ca97b1d938b7a283a14ad34028ab4d011..671fbc2d79353a862e8780579a3e66a4f6c80c80 100644 (file)
@@ -1193,6 +1193,8 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
                                                        u8 *data, int clen)
 {
        u8 buf[1];
+       unsigned long flags;
+
        switch (command) {
        case CMD_CLD: {
                struct gsm_dlci *dlci = gsm->dlci[0];
@@ -1218,7 +1220,9 @@ static void gsm_control_message(struct gsm_mux *gsm, unsigned int command,
                gsm->constipated = 0;
                gsm_control_reply(gsm, CMD_FCOFF, NULL, 0);
                /* Kick the link in case it is idling */
+               spin_lock_irqsave(&gsm->tx_lock, flags);
                gsm_data_kick(gsm);
+               spin_unlock_irqrestore(&gsm->tx_lock, flags);
                break;
        case CMD_MSC:
                /* Out of band modem line change indicator for a DLCI */
@@ -2380,12 +2384,12 @@ static void gsmld_write_wakeup(struct tty_struct *tty)
 
        /* Queue poll */
        clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
+       spin_lock_irqsave(&gsm->tx_lock, flags);
        gsm_data_kick(gsm);
        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);
        }
+       spin_unlock_irqrestore(&gsm->tx_lock, flags);
 }
 
 /**