aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMark Kamichoff <prox@prolixium.com>2011-11-09 06:48:10 -0500
committerDavid S. Miller <davem@davemloft.net>2011-11-14 00:49:05 -0500
commit6d74eb9442fb113c97edc88a1c658462db711337 (patch)
tree746e052b599e0a6923120e2cb29788f92abe21ae /drivers
parent3ac3546e5f17248d961ef0f4a27e75564bf71578 (diff)
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: Mark Kamichoff <prox@prolixium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/usb/cdc_ether.c2
-rw-r--r--drivers/net/usb/lg-vl600.c25
2 files changed, 12 insertions, 15 deletions
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index c924ea2bce0..99ed6eb4dfa 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -567,7 +567,7 @@ static const struct usb_device_id products [] = {
567{ 567{
568 USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, 568 USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM,
569 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), 569 USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE),
570 .driver_info = (unsigned long)&wwan_info, 570 .driver_info = 0,
571}, 571},
572 572
573/* 573/*
diff --git a/drivers/net/usb/lg-vl600.c b/drivers/net/usb/lg-vl600.c
index d43db32f947..9c26c6390d6 100644
--- a/drivers/net/usb/lg-vl600.c
+++ b/drivers/net/usb/lg-vl600.c
@@ -144,10 +144,11 @@ static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
144 } 144 }
145 145
146 frame = (struct vl600_frame_hdr *) buf->data; 146 frame = (struct vl600_frame_hdr *) buf->data;
147 /* NOTE: Should check that frame->magic == 0x53544448? 147 /* Yes, check that frame->magic == 0x53544448 (or 0x44544d48),
148 * Otherwise if we receive garbage at the beginning of the frame 148 * otherwise we may run out of memory w/a bad packet */
149 * we may end up allocating a huge buffer and saving all the 149 if (ntohl(frame->magic) != 0x53544448 &&
150 * future incoming data into it. */ 150 ntohl(frame->magic) != 0x44544d48)
151 goto error;
151 152
152 if (buf->len < sizeof(*frame) || 153 if (buf->len < sizeof(*frame) ||
153 buf->len != le32_to_cpup(&frame->len)) { 154 buf->len != le32_to_cpup(&frame->len)) {
@@ -296,6 +297,11 @@ encapsulate:
296 * overwrite the remaining fields. 297 * overwrite the remaining fields.
297 */ 298 */
298 packet = (struct vl600_pkt_hdr *) skb->data; 299 packet = (struct vl600_pkt_hdr *) skb->data;
300 /* The VL600 wants IPv6 packets to have an IPv4 ethertype
301 * Since this modem only supports IPv4 and IPv6, just set all
302 * frames to 0x0800 (ETH_P_IP)
303 */
304 packet->h_proto = htons(ETH_P_IP);
299 memset(&packet->dummy, 0, sizeof(packet->dummy)); 305 memset(&packet->dummy, 0, sizeof(packet->dummy));
300 packet->len = cpu_to_le32(orig_len); 306 packet->len = cpu_to_le32(orig_len);
301 307
@@ -308,21 +314,12 @@ encapsulate:
308 if (skb->len < full_len) /* Pad */ 314 if (skb->len < full_len) /* Pad */
309 skb_put(skb, full_len - skb->len); 315 skb_put(skb, full_len - skb->len);
310 316
311 /* The VL600 wants IPv6 packets to have an IPv4 ethertype
312 * Check if this is an IPv6 packet, and set the ethertype
313 * to 0x800
314 */
315 if ((skb->data[sizeof(struct vl600_pkt_hdr *) + 0x22] & 0xf0) == 0x60) {
316 skb->data[sizeof(struct vl600_pkt_hdr *) + 0x20] = 0x08;
317 skb->data[sizeof(struct vl600_pkt_hdr *) + 0x21] = 0;
318 }
319
320 return skb; 317 return skb;
321} 318}
322 319
323static const struct driver_info vl600_info = { 320static const struct driver_info vl600_info = {
324 .description = "LG VL600 modem", 321 .description = "LG VL600 modem",
325 .flags = FLAG_ETHER | FLAG_RX_ASSEMBLE, 322 .flags = FLAG_RX_ASSEMBLE | FLAG_WWAN,
326 .bind = vl600_bind, 323 .bind = vl600_bind,
327 .unbind = vl600_unbind, 324 .unbind = vl600_unbind,
328 .status = usbnet_cdc_status, 325 .status = usbnet_cdc_status,