diff options
| author | Wolfram Sang <w.sang@pengutronix.de> | 2010-11-16 12:50:47 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-11-16 12:50:47 -0500 |
| commit | 4c62ab9c538bc09c38093fa079e6902ea4d42b98 (patch) | |
| tree | d67bb872f84197369d82985702b6517a7a3f289a | |
| parent | 3b42a96dc7870c53d20b419185737d3b8f7a7b74 (diff) | |
irda: irttp: allow zero byte packets
Sending zero byte packets is not neccessarily an error (AF_INET accepts it,
too), so just apply a shortcut. This was discovered because of a non-working
software with WINE. See
http://bugs.winehq.org/show_bug.cgi?id=19397#c86
http://thread.gmane.org/gmane.linux.irda.general/1643
for very detailed debugging information and a testcase. Kudos to Wolfgang for
those!
Reported-by: Wolfgang Schwotzer <wolfgang.schwotzer@gmx.net>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: Mike Evans <mike.evans@cardolan.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/irda/irttp.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 285761e77d90..6cfaeaf2a370 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c | |||
| @@ -550,16 +550,23 @@ EXPORT_SYMBOL(irttp_close_tsap); | |||
| 550 | */ | 550 | */ |
| 551 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) | 551 | int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) |
| 552 | { | 552 | { |
| 553 | int ret = -1; | ||
| 554 | |||
| 553 | IRDA_ASSERT(self != NULL, return -1;); | 555 | IRDA_ASSERT(self != NULL, return -1;); |
| 554 | IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); | 556 | IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;); |
| 555 | IRDA_ASSERT(skb != NULL, return -1;); | 557 | IRDA_ASSERT(skb != NULL, return -1;); |
| 556 | 558 | ||
| 557 | IRDA_DEBUG(4, "%s()\n", __func__); | 559 | IRDA_DEBUG(4, "%s()\n", __func__); |
| 558 | 560 | ||
| 561 | /* Take shortcut on zero byte packets */ | ||
| 562 | if (skb->len == 0) { | ||
| 563 | ret = 0; | ||
| 564 | goto err; | ||
| 565 | } | ||
| 566 | |||
| 559 | /* Check that nothing bad happens */ | 567 | /* Check that nothing bad happens */ |
| 560 | if ((skb->len == 0) || (!self->connected)) { | 568 | if (!self->connected) { |
| 561 | IRDA_DEBUG(1, "%s(), No data, or not connected\n", | 569 | IRDA_DEBUG(1, "%s(), Not connected\n", __func__); |
| 562 | __func__); | ||
| 563 | goto err; | 570 | goto err; |
| 564 | } | 571 | } |
| 565 | 572 | ||
| @@ -576,7 +583,7 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb) | |||
| 576 | 583 | ||
| 577 | err: | 584 | err: |
| 578 | dev_kfree_skb(skb); | 585 | dev_kfree_skb(skb); |
| 579 | return -1; | 586 | return ret; |
| 580 | } | 587 | } |
| 581 | EXPORT_SYMBOL(irttp_udata_request); | 588 | EXPORT_SYMBOL(irttp_udata_request); |
| 582 | 589 | ||
| @@ -599,9 +606,15 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb) | |||
| 599 | IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, | 606 | IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__, |
| 600 | skb_queue_len(&self->tx_queue)); | 607 | skb_queue_len(&self->tx_queue)); |
| 601 | 608 | ||
| 609 | /* Take shortcut on zero byte packets */ | ||
| 610 | if (skb->len == 0) { | ||
| 611 | ret = 0; | ||
| 612 | goto err; | ||
| 613 | } | ||
| 614 | |||
| 602 | /* Check that nothing bad happens */ | 615 | /* Check that nothing bad happens */ |
| 603 | if ((skb->len == 0) || (!self->connected)) { | 616 | if (!self->connected) { |
| 604 | IRDA_WARNING("%s: No data, or not connected\n", __func__); | 617 | IRDA_WARNING("%s: Not connected\n", __func__); |
| 605 | ret = -ENOTCONN; | 618 | ret = -ENOTCONN; |
| 606 | goto err; | 619 | goto err; |
| 607 | } | 620 | } |
