n_gsm: don't allow write if state is not DLCI_OPEN
authorGuillaume Lucas <guillaume.lucas@intel.com>
Thu, 12 Apr 2012 14:20:24 +0000 (16:20 +0200)
committerbuildbot <buildbot@intel.com>
Mon, 16 Apr 2012 13:46:13 +0000 (06:46 -0700)
BZ: 31586

The n_gsm code doesn't have protection to avoid to perform
a write if a DLCi is not in the DLCI_OPEN state. This means
that it's possible to have data sending to the modem when
the DLCi is in the DLCI_OPENING state. Means, when the DLCi
is performing the asynchronous open.

To avoid this, this patch fix the write operation to return
the EAGAIN error if the write is not allowed.
Signed-off-by: Guillaume Lucas <guillaume.lucas@intel.com>
Change-Id: I3a98a9960e62a82afe96b1694a0a67727d84f5bb
Reviewed-on: http://android.intel.com:8080/43298
Reviewed-by: Lucas, Guillaume <guillaume.lucas@intel.com>
Reviewed-by: Pillet, VincentX <vincentx.pillet@intel.com>
Reviewed-by: Roulliere, Pierre <pierre.roulliere@intel.com>
Reviewed-by: Robert, Denis <denis.robert@intel.com>
Reviewed-by: Predon, Frederic <frederic.predon@intel.com>
Reviewed-by: Lebsir, SamiX <samix.lebsir@intel.com>
Tested-by: Lebsir, SamiX <samix.lebsir@intel.com>
Tested-by: buildbot <buildbot@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
drivers/tty/n_gsm.c

index 6a99938..38e416a 100644 (file)
@@ -3000,8 +3000,13 @@ static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf,
                                                                    int len)
 {
        struct gsm_dlci *dlci = tty->driver_data;
+       int sent;
+
+       if (dlci->state != DLCI_OPEN)
+               return -EAGAIN;
+
        /* Stuff the bytes into the fifo queue */
-       int sent = kfifo_in_locked(dlci->fifo, buf, len, &dlci->lock);
+       sent = kfifo_in_locked(dlci->fifo, buf, len, &dlci->lock);
        /* Need to kick the channel */
        gsm_dlci_data_kick(dlci);
        return sent;