]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ax25/ax25_out.c
Merge branch 'omap-clock-fixes' of git://git.pwsan.com/linux-2.6
[linux-2.6-omap-h63xx.git] / net / ax25 / ax25_out.c
index f84047d1e8ce1760f35ae81e3b24c1e3448f1be4..bf706f83a5c9b123d2a14f210a7fe19510030590 100644 (file)
@@ -14,7 +14,6 @@
 #include <linux/in.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/sched.h>
 #include <linux/timer.h>
 #include <linux/string.h>
 #include <linux/sockios.h>
@@ -118,6 +117,12 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
        unsigned char *p;
        int frontlen, len, fragno, ka9qfrag, first = 1;
 
+       if (paclen < 16) {
+               WARN_ON_ONCE(1);
+               kfree_skb(skb);
+               return;
+       }
+
        if ((skb->len - 1) > paclen) {
                if (*skb->data == AX25_P_TEXT) {
                        skb_pull(skb, 1); /* skip PID */
@@ -149,8 +154,9 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
 
                        if (ka9qfrag == 1) {
                                skb_reserve(skbn, frontlen + 2);
-                               skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data);
-                               memcpy(skb_put(skbn, len), skb->data, len);
+                               skb_set_network_header(skbn,
+                                                     skb_network_offset(skb));
+                               skb_copy_from_linear_data(skb, skb_put(skbn, len), len);
                                p = skb_push(skbn, 2);
 
                                *p++ = AX25_P_SEGMENT;
@@ -162,8 +168,9 @@ void ax25_output(ax25_cb *ax25, int paclen, struct sk_buff *skb)
                                }
                        } else {
                                skb_reserve(skbn, frontlen + 1);
-                               skbn->nh.raw = skbn->data + (skb->nh.raw - skb->data);
-                               memcpy(skb_put(skbn, len), skb->data, len);
+                               skb_set_network_header(skbn,
+                                                     skb_network_offset(skb));
+                               skb_copy_from_linear_data(skb, skb_put(skbn, len), len);
                                p = skb_push(skbn, 1);
                                *p = AX25_P_TEXT;
                        }
@@ -206,7 +213,7 @@ static void ax25_send_iframe(ax25_cb *ax25, struct sk_buff *skb, int poll_bit)
        if (skb == NULL)
                return;
 
-       skb->nh.raw = skb->data;
+       skb_reset_network_header(skb);
 
        if (ax25->modulus == AX25_MODULUS) {
                frame = skb_push(skb, 1);
@@ -250,8 +257,6 @@ void ax25_kick(ax25_cb *ax25)
        if (start == end)
                return;
 
-       ax25->vs = start;
-
        /*
         * Transmit data until either we're out of data to send or
         * the window is full. Send a poll on the final I frame if
@@ -260,8 +265,13 @@ void ax25_kick(ax25_cb *ax25)
 
        /*
         * Dequeue the frame and copy it.
+        * Check for race with ax25_clear_queues().
         */
        skb  = skb_dequeue(&ax25->write_queue);
+       if (!skb)
+               return;
+
+       ax25->vs = start;
 
        do {
                if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) {