mirror of https://gitee.com/openkylin/linux.git
[IrDA]: Use alloc_skb() in IrDA TX path
As pointed out by Christoph Hellwig, dev_alloc_skb() is not intended to be used for allocating TX sk_buff. The IrDA stack was exclusively calling dev_alloc_skb() on the TX path, and this patch fixes that. Signed-off-by: Samuel Ortiz <samuel@sortiz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b826315813
commit
485fb2c998
|
@ -308,7 +308,7 @@ static void irda_connect_response(struct irda_sock *self)
|
||||||
|
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(64);
|
skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (skb == NULL) {
|
if (skb == NULL) {
|
||||||
IRDA_DEBUG(0, "%s() Unable to allocate sk_buff!\n",
|
IRDA_DEBUG(0, "%s() Unable to allocate sk_buff!\n",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
|
|
|
@ -81,7 +81,7 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
|
||||||
|
|
||||||
/* Any userdata supplied? */
|
/* Any userdata supplied? */
|
||||||
if (userdata == NULL) {
|
if (userdata == NULL) {
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
|
||||||
IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
|
IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
|
||||||
|
|
||||||
if (!userdata) {
|
if (!userdata) {
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
|
||||||
|
|
||||||
skb = self->ctrl_skb;
|
skb = self->ctrl_skb;
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
skb = dev_alloc_skb(256);
|
skb = alloc_skb(256, GFP_ATOMIC);
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
spin_unlock_irqrestore(&self->spinlock, flags);
|
spin_unlock_irqrestore(&self->spinlock, flags);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
@ -759,8 +759,9 @@ static int ircomm_tty_write(struct tty_struct *tty,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Prepare a full sized frame */
|
/* Prepare a full sized frame */
|
||||||
skb = dev_alloc_skb(self->max_data_size+
|
skb = alloc_skb(self->max_data_size+
|
||||||
self->max_header_size);
|
self->max_header_size,
|
||||||
|
GFP_ATOMIC);
|
||||||
if (!skb) {
|
if (!skb) {
|
||||||
spin_unlock_irqrestore(&self->spinlock, flags);
|
spin_unlock_irqrestore(&self->spinlock, flags);
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
|
@ -345,7 +345,7 @@ static void iriap_disconnect_request(struct iriap_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (tx_skb == NULL) {
|
if (tx_skb == NULL) {
|
||||||
IRDA_DEBUG(0, "%s(), Could not allocate an sk_buff of length %d\n",
|
IRDA_DEBUG(0, "%s(), Could not allocate an sk_buff of length %d\n",
|
||||||
__FUNCTION__, 64);
|
__FUNCTION__, 64);
|
||||||
|
@ -396,7 +396,7 @@ int iriap_getvaluebyclass_request(struct iriap_cb *self,
|
||||||
attr_len = strlen(attr); /* Up to IAS_MAX_ATTRIBNAME = 60 */
|
attr_len = strlen(attr); /* Up to IAS_MAX_ATTRIBNAME = 60 */
|
||||||
|
|
||||||
skb_len = self->max_header_size+2+name_len+1+attr_len+4;
|
skb_len = self->max_header_size+2+name_len+1+attr_len+4;
|
||||||
tx_skb = dev_alloc_skb(skb_len);
|
tx_skb = alloc_skb(skb_len, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -562,7 +562,8 @@ static void iriap_getvaluebyclass_response(struct iriap_cb *self,
|
||||||
* value. We add 32 bytes because of the 6 bytes for the frame and
|
* value. We add 32 bytes because of the 6 bytes for the frame and
|
||||||
* max 5 bytes for the value coding.
|
* max 5 bytes for the value coding.
|
||||||
*/
|
*/
|
||||||
tx_skb = dev_alloc_skb(value->len + self->max_header_size + 32);
|
tx_skb = alloc_skb(value->len + self->max_header_size + 32,
|
||||||
|
GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -700,7 +701,7 @@ void iriap_send_ack(struct iriap_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IAS_MAGIC, return;);
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ static void state_r_disconnect(struct iriap_cb *self, IRIAP_EVENT event,
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case IAP_LM_CONNECT_INDICATION:
|
case IAP_LM_CONNECT_INDICATION:
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (tx_skb == NULL) {
|
if (tx_skb == NULL) {
|
||||||
IRDA_WARNING("%s: unable to malloc!\n", __FUNCTION__);
|
IRDA_WARNING("%s: unable to malloc!\n", __FUNCTION__);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -636,7 +636,7 @@ void irlan_get_provider_info(struct irlan_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(64);
|
skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ void irlan_open_data_channel(struct irlan_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(64);
|
skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -704,7 +704,7 @@ void irlan_close_data_channel(struct irlan_cb *self)
|
||||||
if (self->client.tsap_ctrl == NULL)
|
if (self->client.tsap_ctrl == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
skb = dev_alloc_skb(64);
|
skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -739,7 +739,7 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(128);
|
skb = alloc_skb(128, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -777,7 +777,7 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(128);
|
skb = alloc_skb(128, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ void irlan_set_multicast_filter(struct irlan_cb *self, int status)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(128);
|
skb = alloc_skb(128, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(128);
|
skb = alloc_skb(128, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -891,7 +891,7 @@ void irlan_get_media_char(struct irlan_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(64);
|
skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
|
||||||
|
|
||||||
skb = dev_alloc_skb(128);
|
skb = alloc_skb(128, GFP_ATOMIC);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -882,7 +882,7 @@ static void irlap_change_speed(struct irlap_cb *self, __u32 speed, int now)
|
||||||
/* Change speed now, or just piggyback speed on frames */
|
/* Change speed now, or just piggyback speed on frames */
|
||||||
if (now) {
|
if (now) {
|
||||||
/* Send down empty frame to trigger speed change */
|
/* Send down empty frame to trigger speed change */
|
||||||
skb = dev_alloc_skb(0);
|
skb = alloc_skb(0, GFP_ATOMIC);
|
||||||
if (skb)
|
if (skb)
|
||||||
irlap_queue_xmit(self, skb);
|
irlap_queue_xmit(self, skb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ void irlap_send_snrm_frame(struct irlap_cb *self, struct qos_info *qos)
|
||||||
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
||||||
|
|
||||||
/* Allocate frame */
|
/* Allocate frame */
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ void irlap_send_ua_response_frame(struct irlap_cb *self, struct qos_info *qos)
|
||||||
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
||||||
|
|
||||||
/* Allocate frame */
|
/* Allocate frame */
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ void irlap_send_dm_frame( struct irlap_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(32);
|
tx_skb = alloc_skb(32, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ void irlap_send_disc_frame(struct irlap_cb *self)
|
||||||
IRDA_ASSERT(self != NULL, return;);
|
IRDA_ASSERT(self != NULL, return;);
|
||||||
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(16);
|
tx_skb = alloc_skb(16, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -315,7 +315,7 @@ void irlap_send_discovery_xid_frame(struct irlap_cb *self, int S, __u8 s,
|
||||||
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
|
||||||
IRDA_ASSERT(discovery != NULL, return;);
|
IRDA_ASSERT(discovery != NULL, return;);
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ void irlap_send_rr_frame(struct irlap_cb *self, int command)
|
||||||
struct sk_buff *tx_skb;
|
struct sk_buff *tx_skb;
|
||||||
__u8 *frame;
|
__u8 *frame;
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(16);
|
tx_skb = alloc_skb(16, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -601,7 +601,7 @@ void irlap_send_rd_frame(struct irlap_cb *self)
|
||||||
struct sk_buff *tx_skb;
|
struct sk_buff *tx_skb;
|
||||||
__u8 *frame;
|
__u8 *frame;
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(16);
|
tx_skb = alloc_skb(16, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1215,7 +1215,7 @@ void irlap_send_test_frame(struct irlap_cb *self, __u8 caddr, __u32 daddr,
|
||||||
struct test_frame *frame;
|
struct test_frame *frame;
|
||||||
__u8 *info;
|
__u8 *info;
|
||||||
|
|
||||||
tx_skb = dev_alloc_skb(cmd->len+sizeof(struct test_frame));
|
tx_skb = alloc_skb(cmd->len+sizeof(struct test_frame), GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -395,7 +395,7 @@ int irlmp_connect_request(struct lsap_cb *self, __u8 dlsap_sel,
|
||||||
|
|
||||||
/* Any userdata? */
|
/* Any userdata? */
|
||||||
if (tx_skb == NULL) {
|
if (tx_skb == NULL) {
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,8 @@ static inline void irttp_fragment_skb(struct tsap_cb *self,
|
||||||
IRDA_DEBUG(2, "%s(), fragmenting ...\n", __FUNCTION__);
|
IRDA_DEBUG(2, "%s(), fragmenting ...\n", __FUNCTION__);
|
||||||
|
|
||||||
/* Make new segment */
|
/* Make new segment */
|
||||||
frag = dev_alloc_skb(self->max_seg_size+self->max_header_size);
|
frag = alloc_skb(self->max_seg_size+self->max_header_size,
|
||||||
|
GFP_ATOMIC);
|
||||||
if (!frag)
|
if (!frag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -805,7 +806,7 @@ static inline void irttp_give_credit(struct tsap_cb *self)
|
||||||
self->send_credit, self->avail_credit, self->remote_credit);
|
self->send_credit, self->avail_credit, self->remote_credit);
|
||||||
|
|
||||||
/* Give credit to peer */
|
/* Give credit to peer */
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1094,7 +1095,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
|
||||||
|
|
||||||
/* Any userdata supplied? */
|
/* Any userdata supplied? */
|
||||||
if (userdata == NULL) {
|
if (userdata == NULL) {
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1342,7 +1343,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
|
||||||
|
|
||||||
/* Any userdata supplied? */
|
/* Any userdata supplied? */
|
||||||
if (userdata == NULL) {
|
if (userdata == NULL) {
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -1541,7 +1542,7 @@ int irttp_disconnect_request(struct tsap_cb *self, struct sk_buff *userdata,
|
||||||
|
|
||||||
if (!userdata) {
|
if (!userdata) {
|
||||||
struct sk_buff *tx_skb;
|
struct sk_buff *tx_skb;
|
||||||
tx_skb = dev_alloc_skb(64);
|
tx_skb = alloc_skb(64, GFP_ATOMIC);
|
||||||
if (!tx_skb)
|
if (!tx_skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue