Skip to content

Commit 4c62ab9

Browse files
Wolfram Sangdavem330
authored andcommitted
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>
1 parent 3b42a96 commit 4c62ab9

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

‎net/irda/irttp.c‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,16 +550,23 @@ EXPORT_SYMBOL(irttp_close_tsap);
550550
*/
551551
int irttp_udata_request(struct tsap_cb *self, struct sk_buff *skb)
552552
{
553+
int ret = -1;
554+
553555
IRDA_ASSERT(self != NULL, return -1;);
554556
IRDA_ASSERT(self->magic == TTP_TSAP_MAGIC, return -1;);
555557
IRDA_ASSERT(skb != NULL, return -1;);
556558

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

561+
/* Take shortcut on zero byte packets */
562+
if (skb->len == 0) {
563+
ret = 0;
564+
goto err;
565+
}
566+
559567
/* Check that nothing bad happens */
560-
if ((skb->len == 0) || (!self->connected)) {
561-
IRDA_DEBUG(1, "%s(), No data, or not connected\n",
562-
__func__);
568+
if (!self->connected) {
569+
IRDA_DEBUG(1, "%s(), Not connected\n", __func__);
563570
goto err;
564571
}
565572

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

577584
err:
578585
dev_kfree_skb(skb);
579-
return -1;
586+
return ret;
580587
}
581588
EXPORT_SYMBOL(irttp_udata_request);
582589

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

609+
/* Take shortcut on zero byte packets */
610+
if (skb->len == 0) {
611+
ret = 0;
612+
goto err;
613+
}
614+
602615
/* Check that nothing bad happens */
603-
if ((skb->len == 0) || (!self->connected)) {
604-
IRDA_WARNING("%s: No data, or not connected\n", __func__);
616+
if (!self->connected) {
617+
IRDA_WARNING("%s: Not connected\n", __func__);
605618
ret = -ENOTCONN;
606619
goto err;
607620
}

0 commit comments

Comments
 (0)