]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[IrDA]: Memory allocations cleanups
authorSamuel Ortiz <samuel@sortiz.org>
Thu, 28 Sep 2006 03:06:44 +0000 (20:06 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 29 Sep 2006 01:02:48 +0000 (18:02 -0700)
This patch replaces the bunch of arbitrary 64 and 128 bytes alloc_skb() calls
with more accurate allocation sizes.

Signed-off-by: Samuel Ortiz <samuel@sortiz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
include/net/irda/irlan_common.h
include/net/irda/irlap_frame.h
include/net/irda/irlmp.h
net/irda/af_irda.c
net/irda/ircomm/ircomm_lmp.c
net/irda/iriap.c
net/irda/iriap_event.c
net/irda/irlan/irlan_common.c
net/irda/irlan/irlan_provider.c
net/irda/irlap_frame.c
net/irda/irlmp.c
net/irda/irttp.c

index 1c73bdbc3eb3a76332a6312dee8b1e9d7fd58416..9592c374b41d536e182930ff6f16f7a70d71a813 100644 (file)
 #define IRLAN_SHORT  1
 #define IRLAN_ARRAY  2
 
-#define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER+LAP_MAX_HEADER)
+/* IrLAN sits on top if IrTTP */
+#define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER)
+/* 1 byte for the command code and 1 byte for the parameter count */
+#define IRLAN_CMD_HEADER 2
+
+#define IRLAN_STRING_PARAMETER_LEN(name, value) (1 + strlen((name)) + 2 \
+                                               + strlen ((value)))
+#define IRLAN_BYTE_PARAMETER_LEN(name)          (1 + strlen((name)) + 2 + 1)
+#define IRLAN_SHORT_PARAMETER_LEN(name)         (1 + strlen((name)) + 2 + 2)
 
 /*
  *  IrLAN client
index 3452ae257c845d1d3f93460ffc4165756cd9b3f1..9dd54a5002b2af123c3118f09db60838cc05add0 100644 (file)
@@ -74,6 +74,19 @@ struct discovery_t;
 
 #define PF_BIT    0x10 /* Poll/final bit */
 
+/* Some IrLAP field lengths */
+/*
+ * Only baud rate triplet is 4 bytes (PV can be 2 bytes).
+ * All others params (7) are 3 bytes, so that's 7*3 + 1*4 bytes.
+ */
+#define IRLAP_NEGOCIATION_PARAMS_LEN 25
+#define IRLAP_DISCOVERY_INFO_LEN     32
+
+struct disc_frame {
+       __u8 caddr;          /* Connection address */
+       __u8 control;
+} IRDA_PACK;
+
 struct xid_frame {
        __u8  caddr; /* Connection address */
        __u8  control;
@@ -95,11 +108,25 @@ struct test_frame {
 struct ua_frame {
        __u8 caddr;
        __u8 control;
-
        __u32 saddr; /* Source device address */
        __u32 daddr; /* Dest device address */
 } IRDA_PACK;
-       
+
+struct dm_frame {
+       __u8 caddr;          /* Connection address */
+       __u8 control;
+} IRDA_PACK;
+
+struct rd_frame {
+       __u8 caddr;          /* Connection address */
+       __u8 control;
+} IRDA_PACK;
+
+struct rr_frame {
+       __u8 caddr;          /* Connection address */
+       __u8 control;
+} IRDA_PACK;
+
 struct i_frame {
        __u8 caddr;
        __u8 control;
index 11ecfa58a648ff3ad145b8138055f6ac5ad9f54f..e212b9bc2503d64439cd70c3ffa4d080d15751dd 100644 (file)
@@ -48,7 +48,7 @@
 #define DEV_ADDR_ANY  0xffffffff
 
 #define LMP_HEADER          2    /* Dest LSAP + Source LSAP */
-#define LMP_CONTROL_HEADER  4
+#define LMP_CONTROL_HEADER  4    /* LMP_HEADER + opcode + parameter */
 #define LMP_PID_HEADER      1    /* Used by Ultra */
 #define LMP_MAX_HEADER      (LMP_CONTROL_HEADER+LAP_MAX_HEADER)
 
index 7b7cd5bd2a0658e8cf32849061053022f389b625..7e1aea89ef05b60709fcb37e1f5ec531303f0359 100644 (file)
@@ -309,7 +309,8 @@ static void irda_connect_response(struct irda_sock *self)
 
        IRDA_ASSERT(self != NULL, return;);
 
-       skb = alloc_skb(64, GFP_ATOMIC);
+       skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
+                       GFP_ATOMIC);
        if (skb == NULL) {
                IRDA_DEBUG(0, "%s() Unable to allocate sk_buff!\n",
                           __FUNCTION__);
index 959874b6451f00cf9edf4ad23343a1cd07e73b5b..c8e0d89ee11fd3e9443767fd875d05372453bcc5 100644 (file)
@@ -81,7 +81,7 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
        
        /* Any userdata supplied? */
        if (userdata == NULL) {
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
@@ -115,7 +115,7 @@ static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
         if (!userdata) {
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
                
index 61128aa05b4015c9fb85027bd1cc870b34a9beec..415cf4eec23b8e86ac69597dd0ffae6e3f953f44 100644 (file)
@@ -345,10 +345,11 @@ static void iriap_disconnect_request(struct iriap_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
 
-       tx_skb = alloc_skb(64, GFP_ATOMIC);
+       tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
        if (tx_skb == NULL) {
-               IRDA_DEBUG(0, "%s(), Could not allocate an sk_buff of length %d\n", 
-                       __FUNCTION__, 64);
+               IRDA_DEBUG(0,
+                          "%s(), Could not allocate an sk_buff of length %d\n",
+                          __FUNCTION__, LMP_MAX_HEADER);
                return;
        }
 
@@ -701,7 +702,7 @@ void iriap_send_ack(struct iriap_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
 
-       tx_skb = alloc_skb(64, GFP_ATOMIC);
+       tx_skb = alloc_skb(LMP_MAX_HEADER + 1, GFP_ATOMIC);
        if (!tx_skb)
                return;
 
index da17395df05adab0dab896b9e64f59ff1d4f62ab..99b18dc7a0b7e3b26f8fcd52d7c30bebee14d69d 100644 (file)
@@ -365,7 +365,7 @@ static void state_r_disconnect(struct iriap_cb *self, IRIAP_EVENT event,
 
        switch (event) {
        case IAP_LM_CONNECT_INDICATION:
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
                if (tx_skb == NULL) {
                        IRDA_WARNING("%s: unable to malloc!\n", __FUNCTION__);
                        return;
index 7dd0a2fe1d20dfac9a51b60fc4724c64e8c38b84..9b962f247714f5ec71c02f4b1e9822cd1531955e 100644 (file)
@@ -636,7 +636,8 @@ void irlan_get_provider_info(struct irlan_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
 
-       skb = alloc_skb(64, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER,
+                       GFP_ATOMIC);
        if (!skb)
                return;
 
@@ -668,7 +669,10 @@ void irlan_open_data_channel(struct irlan_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        
-       skb = alloc_skb(64, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") +
+                       IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"),
+                       GFP_ATOMIC);
        if (!skb)
                return;
 
@@ -704,7 +708,9 @@ void irlan_close_data_channel(struct irlan_cb *self)
        if (self->client.tsap_ctrl == NULL)
                return;
 
-       skb = alloc_skb(64, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN"),
+                       GFP_ATOMIC);
        if (!skb)
                return;
 
@@ -715,7 +721,7 @@ void irlan_close_data_channel(struct irlan_cb *self)
        
        /* Build frame */
        frame[0] = CMD_CLOSE_DATA_CHAN;
-       frame[1] = 0x01; /* Two parameters */
+       frame[1] = 0x01; /* One parameter */
 
        irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
 
@@ -739,7 +745,11 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);       
        
-       skb = alloc_skb(128, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"),
+                       GFP_ATOMIC);
        if (!skb)
                return;
 
@@ -777,7 +787,12 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        
-       skb = alloc_skb(128, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") +
+                       /* We may waste one byte here...*/
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "FILTER"),
+                       GFP_ATOMIC);
        if (!skb)
                return;
 
@@ -816,7 +831,12 @@ void irlan_set_multicast_filter(struct irlan_cb *self, int status)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
 
-       skb = alloc_skb(128, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") +
+                       /* We may waste one byte here...*/
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_MODE", "NONE"),
+                       GFP_ATOMIC);
        if (!skb)
                return;
        
@@ -856,7 +876,12 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        
-       skb = alloc_skb(128, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_OPERATION",
+                                                  "DYNAMIC"),
+                       GFP_ATOMIC);
        if (!skb)
                return;
 
@@ -891,7 +916,10 @@ void irlan_get_media_char(struct irlan_cb *self)
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
        
-       skb = alloc_skb(64, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"),
+                       GFP_ATOMIC);
+
        if (!skb)
                return;
 
index 9c0df86044d7d4aaeabe71c0be10667dda723a10..58efde919667fb1a18c7ee0436aa53c6c1185f09 100644 (file)
@@ -296,7 +296,14 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
 
-       skb = alloc_skb(128, GFP_ATOMIC);
+       skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
+                       /* Bigger param length comes from CMD_GET_MEDIA_CHAR */
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BORADCAST") +
+                       IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "MULTICAST") +
+                       IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "HOSTED"),
+                       GFP_ATOMIC);
+
        if (!skb)
                return;
 
@@ -354,8 +361,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
                } else
                        skb->data[1] = 0x02; /* 2 parameters */
                irlan_insert_byte_param(skb, "DATA_CHAN", self->stsap_sel_data);
-               irlan_insert_array_param(skb, "RECONNECT_KEY", "LINUX RULES!",
-                                        12);
+               irlan_insert_string_param(skb, "RECONNECT_KEY", "LINUX RULES!");
                break;
        case CMD_FILTER_OPERATION:
                irlan_filter_request(self, skb);
index ccb983bf0f4a222a8f848a0a8162b327c5d01d8e..dba349c832d02454b8451bbd02aa1935e23d9e15 100644 (file)
@@ -117,7 +117,9 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        /* Allocate frame */
-       tx_skb = alloc_skb(64, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct snrm_frame) +
+                          IRLAP_NEGOCIATION_PARAMS_LEN,
+                          GFP_ATOMIC);
        if (!tx_skb)
                return;
 
@@ -136,7 +138,7 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
         *  If we are establishing a connection then insert QoS paramerters
         */
        if (qos) {
-               skb_put(tx_skb, 9); /* 21 left */
+               skb_put(tx_skb, 9); /* 25 left */
                frame->saddr = cpu_to_le32(self->saddr);
                frame->daddr = cpu_to_le32(self->daddr);
 
@@ -210,7 +212,9 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos)
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
        /* Allocate frame */
-       tx_skb = alloc_skb(64, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct ua_frame) +
+                          IRLAP_NEGOCIATION_PARAMS_LEN,
+                          GFP_ATOMIC);
        if (!tx_skb)
                return;
 
@@ -245,23 +249,23 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos)
 void irlap_send_dm_frame( struct irlap_cb *self)
 {
        struct sk_buff *tx_skb = NULL;
-       __u8 *frame;
+       struct dm_frame *frame;
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
-       tx_skb = alloc_skb(32, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct dm_frame), GFP_ATOMIC);
        if (!tx_skb)
                return;
 
-       frame = skb_put(tx_skb, 2);
+       frame = (struct dm_frame *)skb_put(tx_skb, 2);
 
        if (self->state == LAP_NDM)
-               frame[0] = CBROADCAST;
+               frame->caddr = CBROADCAST;
        else
-               frame[0] = self->caddr;
+               frame->caddr = self->caddr;
 
-       frame[1] = DM_RSP | PF_BIT;
+       frame->control = DM_RSP | PF_BIT;
 
        irlap_queue_xmit(self, tx_skb);
 }
@@ -275,21 +279,21 @@ void irlap_send_dm_frame( struct irlap_cb *self)
 void irlap_send_disc_frame(struct irlap_cb *self)
 {
        struct sk_buff *tx_skb = NULL;
-       __u8 *frame;
+       struct disc_frame *frame;
 
        IRDA_DEBUG(3, "%s()\n", __FUNCTION__);
 
        IRDA_ASSERT(self != NULL, return;);
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
 
-       tx_skb = alloc_skb(16, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct disc_frame), GFP_ATOMIC);
        if (!tx_skb)
                return;
 
-       frame = skb_put(tx_skb, 2);
+       frame = (struct disc_frame *)skb_put(tx_skb, 2);
 
-       frame[0] = self->caddr | CMD_FRAME;
-       frame[1] = DISC_CMD | PF_BIT;
+       frame->caddr = self->caddr | CMD_FRAME;
+       frame->control = DISC_CMD | PF_BIT;
 
        irlap_queue_xmit(self, tx_skb);
 }
@@ -315,7 +319,8 @@ void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
        IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
        IRDA_ASSERT(discovery != NULL, return;);
 
-       tx_skb = alloc_skb(64, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct xid_frame) + IRLAP_DISCOVERY_INFO_LEN,
+                          GFP_ATOMIC);
        if (!tx_skb)
                return;
 
@@ -573,18 +578,18 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
 void irlap_send_rr_frame(struct irlap_cb *self, int command)
 {
        struct sk_buff *tx_skb;
-       __u8 *frame;
+       struct rr_frame *frame;
 
-       tx_skb = alloc_skb(16, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct rr_frame), GFP_ATOMIC);
        if (!tx_skb)
                return;
 
-       frame = skb_put(tx_skb, 2);
+       frame = (struct rr_frame *)skb_put(tx_skb, 2);
 
-       frame[0] = self->caddr;
-       frame[0] |= (command) ? CMD_FRAME : 0;
+       frame->caddr = self->caddr;
+       frame->caddr |= (command) ? CMD_FRAME : 0;
 
-       frame[1] = RR | PF_BIT | (self->vr << 5);
+       frame->control = RR | PF_BIT | (self->vr << 5);
 
        irlap_queue_xmit(self, tx_skb);
 }
@@ -598,16 +603,16 @@ void irlap_send_rr_frame(struct irlap_cb *self, int command)
 void irlap_send_rd_frame(struct irlap_cb *self)
 {
        struct sk_buff *tx_skb;
-       __u8 *frame;
+       struct rd_frame *frame;
 
-       tx_skb = alloc_skb(16, GFP_ATOMIC);
+       tx_skb = alloc_skb(sizeof(struct rd_frame), GFP_ATOMIC);
        if (!tx_skb)
                return;
 
-       frame = skb_put(tx_skb, 2);
+       frame = (struct rd_frame *)skb_put(tx_skb, 2);
 
-       frame[0] = self->caddr;
-       frame[1] = RD_RSP | PF_BIT;
+       frame->caddr = self->caddr;
+       frame->caddr = RD_RSP | PF_BIT;
 
        irlap_queue_xmit(self, tx_skb);
 }
@@ -1214,7 +1219,7 @@ void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
        struct test_frame *frame;
        __u8 *info;
 
-       tx_skb = alloc_skb(cmd->len+sizeof(struct test_frame), GFP_ATOMIC);
+       tx_skb = alloc_skb(cmd->len + sizeof(struct test_frame), GFP_ATOMIC);
        if (!tx_skb)
                return;
 
index c440913dee1468358e76cdef1fef6eeaad3d22a5..5073261b9d0c875d7884cf280866f6b324bb36ba 100644 (file)
@@ -392,7 +392,7 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
 
        /* Any userdata? */
        if (tx_skb == NULL) {
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
index 42acf1cde737d4e0b992df9a6d469311385db410..3c2e70b77df16375952f1c0bc889f298a588e8a9 100644 (file)
@@ -804,12 +804,12 @@ static inline void irttp_give_credit(struct tsap_cb *self)
                   self->send_credit, self->avail_credit, self->remote_credit);
 
        /* Give credit to peer */
-       tx_skb = alloc_skb(64, GFP_ATOMIC);
+       tx_skb = alloc_skb(TTP_MAX_HEADER, GFP_ATOMIC);
        if (!tx_skb)
                return;
 
        /* Reserve space for LMP, and LAP header */
-       skb_reserve(tx_skb, self->max_header_size);
+       skb_reserve(tx_skb, LMP_MAX_HEADER);
 
        /*
         *  Since we can transmit and receive frames concurrently,
@@ -1093,7 +1093,8 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
 
        /* Any userdata supplied? */
        if (userdata == NULL) {
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
+                                  GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
@@ -1341,7 +1342,8 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
 
        /* Any userdata supplied? */
        if (userdata == NULL) {
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(TTP_MAX_HEADER + TTP_SAR_HEADER,
+                                  GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
@@ -1540,14 +1542,14 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
 
        if (!userdata) {
                struct sk_buff *tx_skb;
-               tx_skb = alloc_skb(64, GFP_ATOMIC);
+               tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
                if (!tx_skb)
                        return -ENOMEM;
 
                /*
                 *  Reserve space for MUX and LAP header
                 */
-               skb_reserve(tx_skb, TTP_MAX_HEADER);
+               skb_reserve(tx_skb, LMP_MAX_HEADER);
 
                userdata = tx_skb;
        }