Skip to content

Commit 9dc829a

Browse files
Xie Hedavem330
authored andcommitted
drivers/net/wan/lapbether: Fixed the value of hard_header_len
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, then this driver will prepend a length field of 2 bytes, then the underlying Ethernet device will prepend its own header. So, the header length required should be: -1 + 3 + 2 + "the header length needed by the underlying device". This patch fixes kernel panic when this driver is used with AF_PACKET SOCK_DGRAM sockets. Signed-off-by: Xie He <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0f57a1e commit 9dc829a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/wan/lapbether.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ static void lapbeth_setup(struct net_device *dev)
303303
dev->netdev_ops = &lapbeth_netdev_ops;
304304
dev->needs_free_netdev = true;
305305
dev->type = ARPHRD_X25;
306-
dev->hard_header_len = 3;
307306
dev->mtu = 1000;
308307
dev->addr_len = 0;
309308
}
@@ -324,6 +323,14 @@ static int lapbeth_new_device(struct net_device *dev)
324323
if (!ndev)
325324
goto out;
326325

326+
/* When transmitting data:
327+
* first this driver removes a pseudo header of 1 byte,
328+
* then the lapb module prepends an LAPB header of at most 3 bytes,
329+
* then this driver prepends a length field of 2 bytes,
330+
* then the underlying Ethernet device prepends its own header.
331+
*/
332+
ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len;
333+
327334
lapbeth = netdev_priv(ndev);
328335
lapbeth->axdev = ndev;
329336

0 commit comments

Comments
 (0)