Skip to content

Commit c79f428

Browse files
Xie Hedavem330
authored andcommitted
drivers/net/wan/x25_asy: Added needed_headroom and a skb->len check
1. Added a skb->len check This driver expects upper layers to include a pseudo header of 1 byte when passing down a skb for transmission. This driver will read this 1-byte header. This patch added a skb->len check before reading the header to make sure the header exists. 2. Added needed_headroom When this driver transmits data, first this driver will remove a pseudo header of 1 byte, then the lapb module will prepend the LAPB header of 2 or 3 bytes. So the value of needed_headroom in this driver should be 3 - 1. Cc: Willem de Bruijn <[email protected]> Cc: Martin Schiller <[email protected]> Signed-off-by: Xie He <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b06c19d commit c79f428

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

drivers/net/wan/x25_asy.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb,
307307
return NETDEV_TX_OK;
308308
}
309309

310+
/* There should be a pseudo header of 1 byte added by upper layers.
311+
* Check to make sure it is there before reading it.
312+
*/
313+
if (skb->len < 1) {
314+
kfree_skb(skb);
315+
return NETDEV_TX_OK;
316+
}
317+
310318
switch (skb->data[0]) {
311319
case X25_IFACE_DATA:
312320
break;
@@ -752,6 +760,12 @@ static void x25_asy_setup(struct net_device *dev)
752760
dev->type = ARPHRD_X25;
753761
dev->tx_queue_len = 10;
754762

763+
/* When transmitting data:
764+
* first this driver removes a pseudo header of 1 byte,
765+
* then the lapb module prepends an LAPB header of at most 3 bytes.
766+
*/
767+
dev->needed_headroom = 3 - 1;
768+
755769
/* New-style flags. */
756770
dev->flags = IFF_NOARP;
757771
}

0 commit comments

Comments
 (0)