diff options
author | Tilman Schmidt <tilman@imap.cc> | 2009-10-25 05:29:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-10-29 04:37:09 -0400 |
commit | 4dd8230acd20cb456cae02696b3da2986faad258 (patch) | |
tree | ded49543277fdd72784ac7d2dd14311d39b4e4c9 /drivers/isdn/gigaset | |
parent | 22077ebceb44f4097d4677e2a26bc1175143d647 (diff) |
gigaset: fix bad assumptions about CAPI skbuffs
The CAPI interface incorrectly assumed that CAPI messages would always
start at the beginning of the data buffer: fix by treating DATA_B3
messages as the link layer header to their payload data. This fix
changes the way acknowledgement information is propagated through the
hardware specific modules and thereby impacts the ISDN4Linux variant
of the driver, too.
Also some assumptions about methods not being called from interrupt
context turned out to be unwarranted; fix by using dev_kfree_skb_any()
wherever non-interrupt context isn't guaranteed.
Impact: bugfix
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/gigaset')
-rw-r--r-- | drivers/isdn/gigaset/asyncdata.c | 55 | ||||
-rw-r--r-- | drivers/isdn/gigaset/capi.c | 29 | ||||
-rw-r--r-- | drivers/isdn/gigaset/gigaset.h | 2 | ||||
-rw-r--r-- | drivers/isdn/gigaset/i4l.c | 28 | ||||
-rw-r--r-- | drivers/isdn/gigaset/isocdata.c | 6 |
5 files changed, 70 insertions, 50 deletions
diff --git a/drivers/isdn/gigaset/asyncdata.c b/drivers/isdn/gigaset/asyncdata.c index a25216bf475e..256fc4809c81 100644 --- a/drivers/isdn/gigaset/asyncdata.c +++ b/drivers/isdn/gigaset/asyncdata.c | |||
@@ -156,7 +156,7 @@ byte_stuff: | |||
156 | 156 | ||
157 | /* end of frame */ | 157 | /* end of frame */ |
158 | gigaset_isdn_rcv_err(bcs); | 158 | gigaset_isdn_rcv_err(bcs); |
159 | dev_kfree_skb(skb); | 159 | dev_kfree_skb_any(skb); |
160 | } else if (!(inputstate & INS_have_data)) { /* 7E 7E */ | 160 | } else if (!(inputstate & INS_have_data)) { /* 7E 7E */ |
161 | #ifdef CONFIG_GIGASET_DEBUG | 161 | #ifdef CONFIG_GIGASET_DEBUG |
162 | ++bcs->emptycount; | 162 | ++bcs->emptycount; |
@@ -172,7 +172,7 @@ byte_stuff: | |||
172 | "Checksum failed, %u bytes corrupted!\n", | 172 | "Checksum failed, %u bytes corrupted!\n", |
173 | skb->len); | 173 | skb->len); |
174 | gigaset_isdn_rcv_err(bcs); | 174 | gigaset_isdn_rcv_err(bcs); |
175 | dev_kfree_skb(skb); | 175 | dev_kfree_skb_any(skb); |
176 | } else if (likely(skb->len > 2)) { | 176 | } else if (likely(skb->len > 2)) { |
177 | __skb_trim(skb, skb->len - 2); | 177 | __skb_trim(skb, skb->len - 2); |
178 | gigaset_skb_rcvd(bcs, skb); | 178 | gigaset_skb_rcvd(bcs, skb); |
@@ -182,7 +182,7 @@ byte_stuff: | |||
182 | "invalid packet size (%d)\n", skb->len); | 182 | "invalid packet size (%d)\n", skb->len); |
183 | gigaset_isdn_rcv_err(bcs); | 183 | gigaset_isdn_rcv_err(bcs); |
184 | } | 184 | } |
185 | dev_kfree_skb(skb); | 185 | dev_kfree_skb_any(skb); |
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
@@ -430,11 +430,11 @@ EXPORT_SYMBOL_GPL(gigaset_m10x_input); | |||
430 | * opening and closing flags, preserving headroom data. | 430 | * opening and closing flags, preserving headroom data. |
431 | * parameters: | 431 | * parameters: |
432 | * skb skb containing original packet (freed upon return) | 432 | * skb skb containing original packet (freed upon return) |
433 | * headroom number of headroom bytes to preserve | ||
434 | * Return value: | 433 | * Return value: |
435 | * pointer to newly allocated skb containing the result frame | 434 | * pointer to newly allocated skb containing the result frame |
435 | * and the original link layer header, NULL on error | ||
436 | */ | 436 | */ |
437 | static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom) | 437 | static struct sk_buff *HDLC_Encode(struct sk_buff *skb) |
438 | { | 438 | { |
439 | struct sk_buff *hdlc_skb; | 439 | struct sk_buff *hdlc_skb; |
440 | __u16 fcs; | 440 | __u16 fcs; |
@@ -456,17 +456,19 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom) | |||
456 | 456 | ||
457 | /* size of new buffer: original size + number of stuffing bytes | 457 | /* size of new buffer: original size + number of stuffing bytes |
458 | * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes | 458 | * + 2 bytes FCS + 2 stuffing bytes for FCS (if needed) + 2 flag bytes |
459 | * + room for acknowledgement header | 459 | * + room for link layer header |
460 | */ | 460 | */ |
461 | hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + headroom); | 461 | hdlc_skb = dev_alloc_skb(skb->len + stuf_cnt + 6 + skb->mac_len); |
462 | if (!hdlc_skb) { | 462 | if (!hdlc_skb) { |
463 | dev_kfree_skb(skb); | 463 | dev_kfree_skb_any(skb); |
464 | return NULL; | 464 | return NULL; |
465 | } | 465 | } |
466 | 466 | ||
467 | /* Copy acknowledgement header into new skb */ | 467 | /* Copy link layer header into new skb */ |
468 | skb_reserve(hdlc_skb, headroom); | 468 | skb_reset_mac_header(hdlc_skb); |
469 | memcpy(hdlc_skb->head, skb->head, headroom); | 469 | skb_reserve(hdlc_skb, skb->mac_len); |
470 | memcpy(skb_mac_header(hdlc_skb), skb_mac_header(skb), skb->mac_len); | ||
471 | hdlc_skb->mac_len = skb->mac_len; | ||
470 | 472 | ||
471 | /* Add flag sequence in front of everything.. */ | 473 | /* Add flag sequence in front of everything.. */ |
472 | *(skb_put(hdlc_skb, 1)) = PPP_FLAG; | 474 | *(skb_put(hdlc_skb, 1)) = PPP_FLAG; |
@@ -497,7 +499,7 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom) | |||
497 | 499 | ||
498 | *(skb_put(hdlc_skb, 1)) = PPP_FLAG; | 500 | *(skb_put(hdlc_skb, 1)) = PPP_FLAG; |
499 | 501 | ||
500 | dev_kfree_skb(skb); | 502 | dev_kfree_skb_any(skb); |
501 | return hdlc_skb; | 503 | return hdlc_skb; |
502 | } | 504 | } |
503 | 505 | ||
@@ -506,28 +508,33 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb, int headroom) | |||
506 | * preserving headroom data. | 508 | * preserving headroom data. |
507 | * parameters: | 509 | * parameters: |
508 | * skb skb containing original packet (freed upon return) | 510 | * skb skb containing original packet (freed upon return) |
509 | * headroom number of headroom bytes to preserve | ||
510 | * Return value: | 511 | * Return value: |
511 | * pointer to newly allocated skb containing the result frame | 512 | * pointer to newly allocated skb containing the result frame |
513 | * and the original link layer header, NULL on error | ||
512 | */ | 514 | */ |
513 | static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom) | 515 | static struct sk_buff *iraw_encode(struct sk_buff *skb) |
514 | { | 516 | { |
515 | struct sk_buff *iraw_skb; | 517 | struct sk_buff *iraw_skb; |
516 | unsigned char c; | 518 | unsigned char c; |
517 | unsigned char *cp; | 519 | unsigned char *cp; |
518 | int len; | 520 | int len; |
519 | 521 | ||
520 | /* worst case: every byte must be stuffed */ | 522 | /* size of new buffer (worst case = every byte must be stuffed): |
521 | iraw_skb = dev_alloc_skb(2*skb->len + headroom); | 523 | * 2 * original size + room for link layer header |
524 | */ | ||
525 | iraw_skb = dev_alloc_skb(2*skb->len + skb->mac_len); | ||
522 | if (!iraw_skb) { | 526 | if (!iraw_skb) { |
523 | dev_kfree_skb(skb); | 527 | dev_kfree_skb_any(skb); |
524 | return NULL; | 528 | return NULL; |
525 | } | 529 | } |
526 | 530 | ||
527 | /* Copy acknowledgement header into new skb */ | 531 | /* copy link layer header into new skb */ |
528 | skb_reserve(iraw_skb, headroom); | 532 | skb_reset_mac_header(iraw_skb); |
529 | memcpy(iraw_skb->head, skb->head, headroom); | 533 | skb_reserve(iraw_skb, skb->mac_len); |
534 | memcpy(skb_mac_header(iraw_skb), skb_mac_header(skb), skb->mac_len); | ||
535 | iraw_skb->mac_len = skb->mac_len; | ||
530 | 536 | ||
537 | /* copy and stuff data */ | ||
531 | cp = skb->data; | 538 | cp = skb->data; |
532 | len = skb->len; | 539 | len = skb->len; |
533 | while (len--) { | 540 | while (len--) { |
@@ -536,7 +543,7 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom) | |||
536 | *(skb_put(iraw_skb, 1)) = c; | 543 | *(skb_put(iraw_skb, 1)) = c; |
537 | *(skb_put(iraw_skb, 1)) = c; | 544 | *(skb_put(iraw_skb, 1)) = c; |
538 | } | 545 | } |
539 | dev_kfree_skb(skb); | 546 | dev_kfree_skb_any(skb); |
540 | return iraw_skb; | 547 | return iraw_skb; |
541 | } | 548 | } |
542 | 549 | ||
@@ -548,7 +555,7 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb, int headroom) | |||
548 | * Called by LL to encode and queue an skb for sending, and start | 555 | * Called by LL to encode and queue an skb for sending, and start |
549 | * transmission if necessary. | 556 | * transmission if necessary. |
550 | * Once the payload data has been transmitted completely, gigaset_skb_sent() | 557 | * Once the payload data has been transmitted completely, gigaset_skb_sent() |
551 | * will be called with the first cs->hw_hdr_len bytes of skb->head preserved. | 558 | * will be called with the skb's link layer header preserved. |
552 | * | 559 | * |
553 | * Return value: | 560 | * Return value: |
554 | * number of bytes accepted for sending (skb->len) if ok, | 561 | * number of bytes accepted for sending (skb->len) if ok, |
@@ -560,9 +567,9 @@ int gigaset_m10x_send_skb(struct bc_state *bcs, struct sk_buff *skb) | |||
560 | unsigned long flags; | 567 | unsigned long flags; |
561 | 568 | ||
562 | if (bcs->proto2 == L2_HDLC) | 569 | if (bcs->proto2 == L2_HDLC) |
563 | skb = HDLC_Encode(skb, bcs->cs->hw_hdr_len); | 570 | skb = HDLC_Encode(skb); |
564 | else | 571 | else |
565 | skb = iraw_encode(skb, bcs->cs->hw_hdr_len); | 572 | skb = iraw_encode(skb); |
566 | if (!skb) { | 573 | if (!skb) { |
567 | dev_err(bcs->cs->dev, | 574 | dev_err(bcs->cs->dev, |
568 | "unable to allocate memory for encoding!\n"); | 575 | "unable to allocate memory for encoding!\n"); |
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c index d1afac2bf650..3f5cd06af104 100644 --- a/drivers/isdn/gigaset/capi.c +++ b/drivers/isdn/gigaset/capi.c | |||
@@ -362,6 +362,7 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb) | |||
362 | struct cardstate *cs = bcs->cs; | 362 | struct cardstate *cs = bcs->cs; |
363 | struct gigaset_capi_ctr *iif = cs->iif; | 363 | struct gigaset_capi_ctr *iif = cs->iif; |
364 | struct gigaset_capi_appl *ap = bcs->ap; | 364 | struct gigaset_capi_appl *ap = bcs->ap; |
365 | unsigned char *req = skb_mac_header(dskb); | ||
365 | struct sk_buff *cskb; | 366 | struct sk_buff *cskb; |
366 | u16 flags; | 367 | u16 flags; |
367 | 368 | ||
@@ -380,7 +381,7 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb) | |||
380 | } | 381 | } |
381 | 382 | ||
382 | /* ToDo: honor unset "delivery confirmation" bit */ | 383 | /* ToDo: honor unset "delivery confirmation" bit */ |
383 | flags = CAPIMSG_FLAGS(dskb->head); | 384 | flags = CAPIMSG_FLAGS(req); |
384 | 385 | ||
385 | /* build DATA_B3_CONF message */ | 386 | /* build DATA_B3_CONF message */ |
386 | cskb = alloc_skb(CAPI_DATA_B3_CONF_LEN, GFP_ATOMIC); | 387 | cskb = alloc_skb(CAPI_DATA_B3_CONF_LEN, GFP_ATOMIC); |
@@ -393,11 +394,11 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *dskb) | |||
393 | CAPIMSG_SETAPPID(cskb->data, ap->id); | 394 | CAPIMSG_SETAPPID(cskb->data, ap->id); |
394 | CAPIMSG_SETCOMMAND(cskb->data, CAPI_DATA_B3); | 395 | CAPIMSG_SETCOMMAND(cskb->data, CAPI_DATA_B3); |
395 | CAPIMSG_SETSUBCOMMAND(cskb->data, CAPI_CONF); | 396 | CAPIMSG_SETSUBCOMMAND(cskb->data, CAPI_CONF); |
396 | CAPIMSG_SETMSGID(cskb->data, CAPIMSG_MSGID(dskb->head)); | 397 | CAPIMSG_SETMSGID(cskb->data, CAPIMSG_MSGID(req)); |
397 | CAPIMSG_SETCONTROLLER(cskb->data, iif->ctr.cnr); | 398 | CAPIMSG_SETCONTROLLER(cskb->data, iif->ctr.cnr); |
398 | CAPIMSG_SETPLCI_PART(cskb->data, bcs->channel + 1); | 399 | CAPIMSG_SETPLCI_PART(cskb->data, bcs->channel + 1); |
399 | CAPIMSG_SETNCCI_PART(cskb->data, 1); | 400 | CAPIMSG_SETNCCI_PART(cskb->data, 1); |
400 | CAPIMSG_SETHANDLE_CONF(cskb->data, CAPIMSG_HANDLE_REQ(dskb->head)); | 401 | CAPIMSG_SETHANDLE_CONF(cskb->data, CAPIMSG_HANDLE_REQ(req)); |
401 | if (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION) | 402 | if (flags & ~CAPI_FLAGS_DELIVERY_CONFIRMATION) |
402 | CAPIMSG_SETINFO_CONF(cskb->data, | 403 | CAPIMSG_SETINFO_CONF(cskb->data, |
403 | CapiFlagsNotSupportedByProtocol); | 404 | CapiFlagsNotSupportedByProtocol); |
@@ -437,7 +438,7 @@ void gigaset_skb_rcvd(struct bc_state *bcs, struct sk_buff *skb) | |||
437 | /* don't send further B3 messages if disconnected */ | 438 | /* don't send further B3 messages if disconnected */ |
438 | if (ap->connected < APCONN_ACTIVE) { | 439 | if (ap->connected < APCONN_ACTIVE) { |
439 | gig_dbg(DEBUG_LLDATA, "disconnected, discarding data"); | 440 | gig_dbg(DEBUG_LLDATA, "disconnected, discarding data"); |
440 | dev_kfree_skb(skb); | 441 | dev_kfree_skb_any(skb); |
441 | return; | 442 | return; |
442 | } | 443 | } |
443 | 444 | ||
@@ -1461,7 +1462,7 @@ static void do_connect_resp(struct gigaset_capi_ctr *iif, | |||
1461 | /* decode message */ | 1462 | /* decode message */ |
1462 | capi_message2cmsg(cmsg, skb->data); | 1463 | capi_message2cmsg(cmsg, skb->data); |
1463 | dump_cmsg(DEBUG_CMD, __func__, cmsg); | 1464 | dump_cmsg(DEBUG_CMD, __func__, cmsg); |
1464 | dev_kfree_skb(skb); | 1465 | dev_kfree_skb_any(skb); |
1465 | 1466 | ||
1466 | /* extract and check channel number from PLCI */ | 1467 | /* extract and check channel number from PLCI */ |
1467 | channel = (cmsg->adr.adrPLCI >> 8) & 0xff; | 1468 | channel = (cmsg->adr.adrPLCI >> 8) & 0xff; |
@@ -1652,7 +1653,7 @@ static void do_connect_b3_resp(struct gigaset_capi_ctr *iif, | |||
1652 | ((cmsg->adr.adrNCCI >> 16) & 0xffff) != 1) { | 1653 | ((cmsg->adr.adrNCCI >> 16) & 0xffff) != 1) { |
1653 | dev_notice(cs->dev, "%s: invalid %s 0x%02x\n", | 1654 | dev_notice(cs->dev, "%s: invalid %s 0x%02x\n", |
1654 | "CONNECT_B3_RESP", "NCCI", cmsg->adr.adrNCCI); | 1655 | "CONNECT_B3_RESP", "NCCI", cmsg->adr.adrNCCI); |
1655 | dev_kfree_skb(skb); | 1656 | dev_kfree_skb_any(skb); |
1656 | return; | 1657 | return; |
1657 | } | 1658 | } |
1658 | bcs = &cs->bcs[channel-1]; | 1659 | bcs = &cs->bcs[channel-1]; |
@@ -1665,7 +1666,7 @@ static void do_connect_b3_resp(struct gigaset_capi_ctr *iif, | |||
1665 | if (!gigaset_add_event(cs, &bcs->at_state, | 1666 | if (!gigaset_add_event(cs, &bcs->at_state, |
1666 | EV_HUP, NULL, 0, NULL)) { | 1667 | EV_HUP, NULL, 0, NULL)) { |
1667 | dev_err(cs->dev, "%s: out of memory\n", __func__); | 1668 | dev_err(cs->dev, "%s: out of memory\n", __func__); |
1668 | dev_kfree_skb(skb); | 1669 | dev_kfree_skb_any(skb); |
1669 | return; | 1670 | return; |
1670 | } | 1671 | } |
1671 | gig_dbg(DEBUG_CMD, "scheduling HUP"); | 1672 | gig_dbg(DEBUG_CMD, "scheduling HUP"); |
@@ -1880,12 +1881,12 @@ static void do_data_b3_req(struct gigaset_capi_ctr *iif, | |||
1880 | return; | 1881 | return; |
1881 | } | 1882 | } |
1882 | 1883 | ||
1883 | /* | 1884 | /* pull CAPI message into link layer header */ |
1884 | * pull CAPI message from skb, | 1885 | skb_reset_mac_header(skb); |
1885 | * pass payload data to device-specific module | 1886 | skb->mac_len = msglen; |
1886 | * CAPI message will be preserved in headroom | ||
1887 | */ | ||
1888 | skb_pull(skb, msglen); | 1887 | skb_pull(skb, msglen); |
1888 | |||
1889 | /* pass to device-specific module */ | ||
1889 | if (cs->ops->send_skb(&cs->bcs[channel-1], skb) < 0) { | 1890 | if (cs->ops->send_skb(&cs->bcs[channel-1], skb) < 0) { |
1890 | send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); | 1891 | send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); |
1891 | return; | 1892 | return; |
@@ -1946,7 +1947,7 @@ static void do_nothing(struct gigaset_capi_ctr *iif, | |||
1946 | capi_message2cmsg(&iif->acmsg, skb->data); | 1947 | capi_message2cmsg(&iif->acmsg, skb->data); |
1947 | dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg); | 1948 | dump_cmsg(DEBUG_CMD, __func__, &iif->acmsg); |
1948 | } | 1949 | } |
1949 | dev_kfree_skb(skb); | 1950 | dev_kfree_skb_any(skb); |
1950 | } | 1951 | } |
1951 | 1952 | ||
1952 | static void do_data_b3_resp(struct gigaset_capi_ctr *iif, | 1953 | static void do_data_b3_resp(struct gigaset_capi_ctr *iif, |
@@ -1954,7 +1955,7 @@ static void do_data_b3_resp(struct gigaset_capi_ctr *iif, | |||
1954 | struct sk_buff *skb) | 1955 | struct sk_buff *skb) |
1955 | { | 1956 | { |
1956 | dump_rawmsg(DEBUG_LLDATA, __func__, skb->data); | 1957 | dump_rawmsg(DEBUG_LLDATA, __func__, skb->data); |
1957 | dev_kfree_skb(skb); | 1958 | dev_kfree_skb_any(skb); |
1958 | } | 1959 | } |
1959 | 1960 | ||
1960 | /* table of outgoing CAPI message handlers with lookup function */ | 1961 | /* table of outgoing CAPI message handlers with lookup function */ |
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index 4749ef100fd3..c59216b9c1d0 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h | |||
@@ -625,7 +625,7 @@ struct gigaset_ops { | |||
625 | 625 | ||
626 | /* Called from LL interface to put an skb into the send-queue. | 626 | /* Called from LL interface to put an skb into the send-queue. |
627 | * After sending is completed, gigaset_skb_sent() must be called | 627 | * After sending is completed, gigaset_skb_sent() must be called |
628 | * with the first cs->hw_hdr_len bytes of skb->head preserved. */ | 628 | * with the skb's link layer header preserved. */ |
629 | int (*send_skb)(struct bc_state *bcs, struct sk_buff *skb); | 629 | int (*send_skb)(struct bc_state *bcs, struct sk_buff *skb); |
630 | 630 | ||
631 | /* Called from ev-layer.c to process a block of data | 631 | /* Called from ev-layer.c to process a block of data |
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c index aca72a06184e..828824f905c4 100644 --- a/drivers/isdn/gigaset/i4l.c +++ b/drivers/isdn/gigaset/i4l.c | |||
@@ -41,8 +41,8 @@ static int writebuf_from_LL(int driverID, int channel, int ack, | |||
41 | { | 41 | { |
42 | struct cardstate *cs; | 42 | struct cardstate *cs; |
43 | struct bc_state *bcs; | 43 | struct bc_state *bcs; |
44 | unsigned char *ack_header; | ||
44 | unsigned len; | 45 | unsigned len; |
45 | unsigned skblen; | ||
46 | 46 | ||
47 | if (!(cs = gigaset_get_cs_by_id(driverID))) { | 47 | if (!(cs = gigaset_get_cs_by_id(driverID))) { |
48 | pr_err("%s: invalid driver ID (%d)\n", __func__, driverID); | 48 | pr_err("%s: invalid driver ID (%d)\n", __func__, driverID); |
@@ -78,11 +78,23 @@ static int writebuf_from_LL(int driverID, int channel, int ack, | |||
78 | return -EINVAL; | 78 | return -EINVAL; |
79 | } | 79 | } |
80 | 80 | ||
81 | skblen = ack ? len : 0; | 81 | /* set up acknowledgement header */ |
82 | skb->head[0] = skblen & 0xff; | 82 | if (skb_headroom(skb) < HW_HDR_LEN) { |
83 | skb->head[1] = skblen >> 8; | 83 | /* should never happen */ |
84 | gig_dbg(DEBUG_MCMD, "skb: len=%u, skblen=%u: %02x %02x", | 84 | dev_err(cs->dev, "%s: insufficient skb headroom\n", __func__); |
85 | len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]); | 85 | return -ENOMEM; |
86 | } | ||
87 | skb_set_mac_header(skb, -HW_HDR_LEN); | ||
88 | skb->mac_len = HW_HDR_LEN; | ||
89 | ack_header = skb_mac_header(skb); | ||
90 | if (ack) { | ||
91 | ack_header[0] = len & 0xff; | ||
92 | ack_header[1] = len >> 8; | ||
93 | } else { | ||
94 | ack_header[0] = ack_header[1] = 0; | ||
95 | } | ||
96 | gig_dbg(DEBUG_MCMD, "skb: len=%u, ack=%d: %02x %02x", | ||
97 | len, ack, ack_header[0], ack_header[1]); | ||
86 | 98 | ||
87 | /* pass to device-specific module */ | 99 | /* pass to device-specific module */ |
88 | return cs->ops->send_skb(bcs, skb); | 100 | return cs->ops->send_skb(bcs, skb); |
@@ -99,6 +111,7 @@ static int writebuf_from_LL(int driverID, int channel, int ack, | |||
99 | void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb) | 111 | void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb) |
100 | { | 112 | { |
101 | isdn_if *iif = bcs->cs->iif; | 113 | isdn_if *iif = bcs->cs->iif; |
114 | unsigned char *ack_header = skb_mac_header(skb); | ||
102 | unsigned len; | 115 | unsigned len; |
103 | isdn_ctrl response; | 116 | isdn_ctrl response; |
104 | 117 | ||
@@ -108,8 +121,7 @@ void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb) | |||
108 | dev_warn(bcs->cs->dev, "%s: skb->len==%d\n", | 121 | dev_warn(bcs->cs->dev, "%s: skb->len==%d\n", |
109 | __func__, skb->len); | 122 | __func__, skb->len); |
110 | 123 | ||
111 | len = (unsigned char) skb->head[0] | | 124 | len = ack_header[0] + ((unsigned) ack_header[1] << 8); |
112 | (unsigned) (unsigned char) skb->head[1] << 8; | ||
113 | if (len) { | 125 | if (len) { |
114 | gig_dbg(DEBUG_MCMD, "ACKing to LL (id: %d, ch: %d, sz: %u)", | 126 | gig_dbg(DEBUG_MCMD, "ACKing to LL (id: %d, ch: %d, sz: %u)", |
115 | bcs->cs->myid, bcs->channel, len); | 127 | bcs->cs->myid, bcs->channel, len); |
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c index 7dabfd35874c..bc41611e541d 100644 --- a/drivers/isdn/gigaset/isocdata.c +++ b/drivers/isdn/gigaset/isocdata.c | |||
@@ -576,12 +576,12 @@ static inline void hdlc_done(struct bc_state *bcs) | |||
576 | dev_notice(cs->dev, "received short frame (%d octets)\n", | 576 | dev_notice(cs->dev, "received short frame (%d octets)\n", |
577 | procskb->len); | 577 | procskb->len); |
578 | bcs->hw.bas->runts++; | 578 | bcs->hw.bas->runts++; |
579 | dev_kfree_skb(procskb); | 579 | dev_kfree_skb_any(procskb); |
580 | gigaset_isdn_rcv_err(bcs); | 580 | gigaset_isdn_rcv_err(bcs); |
581 | } else if (bcs->fcs != PPP_GOODFCS) { | 581 | } else if (bcs->fcs != PPP_GOODFCS) { |
582 | dev_notice(cs->dev, "frame check error (0x%04x)\n", bcs->fcs); | 582 | dev_notice(cs->dev, "frame check error (0x%04x)\n", bcs->fcs); |
583 | bcs->hw.bas->fcserrs++; | 583 | bcs->hw.bas->fcserrs++; |
584 | dev_kfree_skb(procskb); | 584 | dev_kfree_skb_any(procskb); |
585 | gigaset_isdn_rcv_err(bcs); | 585 | gigaset_isdn_rcv_err(bcs); |
586 | } else { | 586 | } else { |
587 | len = procskb->len; | 587 | len = procskb->len; |
@@ -985,7 +985,7 @@ void gigaset_isoc_input(struct inbuf_t *inbuf) | |||
985 | * Called by LL to queue an skb for sending, and start transmission if | 985 | * Called by LL to queue an skb for sending, and start transmission if |
986 | * necessary. | 986 | * necessary. |
987 | * Once the payload data has been transmitted completely, gigaset_skb_sent() | 987 | * Once the payload data has been transmitted completely, gigaset_skb_sent() |
988 | * will be called with the first cs->hw_hdr_len bytes of skb->head preserved. | 988 | * will be called with the skb's link layer header preserved. |
989 | * | 989 | * |
990 | * Return value: | 990 | * Return value: |
991 | * number of bytes accepted for sending (skb->len) if ok, | 991 | * number of bytes accepted for sending (skb->len) if ok, |