Skip to content

Commit

Permalink
irda: irttp: allow zero byte packets
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wolfram Sang authored and David S. Miller committed Nov 16, 2010
1 parent 3b42a96 commit 4c62ab9
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions net/irda/irttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,16 +550,23 @@ EXPORT_SYMBOL(irttp_close_tsap);
*/
int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
{
int ret = -1;

IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
IRDA_ASSERT(skb != NULL, return -1;);

IRDA_DEBUG(4, "%s()\n", __func__);

/* Take shortcut on zero byte packets */
if (skb->len == 0) {
ret = 0;
goto err;
}

/* Check that nothing bad happens */
if ((skb->len == 0) || (!self->connected)) {
IRDA_DEBUG(1, "%s(), No data, or not connected\n",
__func__);
if (!self->connected) {
IRDA_DEBUG(1, "%s(), Not connected\n", __func__);
goto err;
}

Expand All @@ -576,7 +583,7 @@ int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)

err:
dev_kfree_skb(skb);
return -1;
return ret;
}
EXPORT_SYMBOL(irttp_udata_request);

Expand All @@ -599,9 +606,15 @@ int irttp_data_request(struct tsap_cb *self, struct sk_buff *skb)
IRDA_DEBUG(2, "%s() : queue len = %d\n", __func__,
skb_queue_len(&self->tx_queue));

/* Take shortcut on zero byte packets */
if (skb->len == 0) {
ret = 0;
goto err;
}

/* Check that nothing bad happens */
if ((skb->len == 0) || (!self->connected)) {
IRDA_WARNING("%s: No data, or not connected\n", __func__);
if (!self->connected) {
IRDA_WARNING("%s: Not connected\n", __func__);
ret = -ENOTCONN;
goto err;
}
Expand Down

0 comments on commit 4c62ab9

Please sign in to comment.