]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
n_gsm: memory leak in uplink error path
authorRuss Gorby <russ.gorby@intel.com>
Mon, 13 Aug 2012 12:45:30 +0000 (13:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Oct 2012 15:39:34 +0000 (08:39 -0700)
commit 88ed2a60610974443335c924d7cb8e5dcf9dbdc1 upstream.

Uplink (TX) network data will go through gsm_dlci_data_output_framed
there is a bug where if memory allocation fails, the skb which
has already been pulled off the list will be lost.

In addition TX skbs were being processed in LIFO order

Fixed the memory leak, and changed to FIFO order processing

Signed-off-by: Russ Gorby <russ.gorby@intel.com>
Tested-by: Kappel, LaurentX <laurentx.kappel@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 671fbc2d79353a862e8780579a3e66a4f6c80c80..90dff8233efdc0817faa1d8b2b13a48f77849035 100644 (file)
@@ -875,7 +875,7 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
 
        /* dlci->skb is locked by tx_lock */
        if (dlci->skb == NULL) {
-               dlci->skb = skb_dequeue(&dlci->skb_list);
+               dlci->skb = skb_dequeue_tail(&dlci->skb_list);
                if (dlci->skb == NULL)
                        return 0;
                first = 1;
@@ -899,8 +899,11 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
 
        /* FIXME: need a timer or something to kick this so it can't
           get stuck with no work outstanding and no buffer free */
-       if (msg == NULL)
+       if (msg == NULL) {
+               skb_queue_tail(&dlci->skb_list, dlci->skb);
+               dlci->skb = NULL;
                return -ENOMEM;
+       }
        dp = msg->data;
 
        if (dlci->adaption == 4) { /* Interruptible framed (Packetised Data) */