Commit 6d74eb94 authored by Mark Kamichoff's avatar Mark Kamichoff Committed by David S. Miller

net/usb: Misc. fixes for the LG-VL600 LTE USB modem

Add checking for valid magic values (needed for stability in the event
corrupted packets are received) and remove some other unneeded checks.
Also, fix flagging device as WWAN (Bugzilla bug #39952).
Signed-off-by: default avatarMark Kamichoff <prox@prolixium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3ac3546e
...@@ -567,7 +567,7 @@ static const struct usb_device_id products [] = { ...@@ -567,7 +567,7 @@ static const struct usb_device_id products [] = {
{ {
USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
.driver_info = (unsigned long)&wwan_info, .driver_info = 0,
}, },
/* /*
......
...@@ -144,10 +144,11 @@ static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ...@@ -144,10 +144,11 @@ static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
} }
frame = (struct vl600_frame_hdr *) buf->data; frame = (struct vl600_frame_hdr *) buf->data;
/* NOTE: Should check that frame->magic == 0x53544448? /* Yes, check that frame->magic == 0x53544448 (or 0x44544d48),
* Otherwise if we receive garbage at the beginning of the frame * otherwise we may run out of memory w/a bad packet */
* we may end up allocating a huge buffer and saving all the if (ntohl(frame->magic) != 0x53544448 &&
* future incoming data into it. */ ntohl(frame->magic) != 0x44544d48)
goto error;
if (buf->len < sizeof(*frame) || if (buf->len < sizeof(*frame) ||
buf->len != le32_to_cpup(&frame->len)) { buf->len != le32_to_cpup(&frame->len)) {
...@@ -296,6 +297,11 @@ static struct sk_buff *vl600_tx_fixup(struct usbnet *dev, ...@@ -296,6 +297,11 @@ static struct sk_buff *vl600_tx_fixup(struct usbnet *dev,
* overwrite the remaining fields. * overwrite the remaining fields.
*/ */
packet = (struct vl600_pkt_hdr *) skb->data; packet = (struct vl600_pkt_hdr *) skb->data;
/* The VL600 wants IPv6 packets to have an IPv4 ethertype
* Since this modem only supports IPv4 and IPv6, just set all
* frames to 0x0800 (ETH_P_IP)
*/
packet->h_proto = htons(ETH_P_IP);
memset(&packet->dummy, 0, sizeof(packet->dummy)); memset(&packet->dummy, 0, sizeof(packet->dummy));
packet->len = cpu_to_le32(orig_len); packet->len = cpu_to_le32(orig_len);
...@@ -308,21 +314,12 @@ static struct sk_buff *vl600_tx_fixup(struct usbnet *dev, ...@@ -308,21 +314,12 @@ static struct sk_buff *vl600_tx_fixup(struct usbnet *dev,
if (skb->len < full_len) /* Pad */ if (skb->len < full_len) /* Pad */
skb_put(skb, full_len - skb->len); skb_put(skb, full_len - skb->len);
/* The VL600 wants IPv6 packets to have an IPv4 ethertype
* Check if this is an IPv6 packet, and set the ethertype
* to 0x800
*/
if ((skb->data[sizeof(struct vl600_pkt_hdr *) + 0x22] & 0xf0) == 0x60) {
skb->data[sizeof(struct vl600_pkt_hdr *) + 0x20] = 0x08;
skb->data[sizeof(struct vl600_pkt_hdr *) + 0x21] = 0;
}
return skb; return skb;
} }
static const struct driver_info vl600_info = { static const struct driver_info vl600_info = {
.description = "LG VL600 modem", .description = "LG VL600 modem",
.flags = FLAG_ETHER | FLAG_RX_ASSEMBLE, .flags = FLAG_RX_ASSEMBLE | FLAG_WWAN,
.bind = vl600_bind, .bind = vl600_bind,
.unbind = vl600_unbind, .unbind = vl600_unbind,
.status = usbnet_cdc_status, .status = usbnet_cdc_status,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment