staging: gdm724x: check for overflow in gdm_lte_netif_rx()
[linux-2.6-microblaze.git] / drivers / staging / gdm724x / gdm_lte.c
index d4dfaea..e390c92 100644 (file)
@@ -611,10 +611,12 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf,
                                                  * bytes (99,130,83,99 dec)
                                                  */
                        } __packed;
-                       void *addr = buf + sizeof(struct iphdr) +
-                               sizeof(struct udphdr) +
-                               offsetof(struct dhcp_packet, chaddr);
-                       ether_addr_copy(nic->dest_mac_addr, addr);
+                       int offset = sizeof(struct iphdr) +
+                                    sizeof(struct udphdr) +
+                                    offsetof(struct dhcp_packet, chaddr);
+                       if (offset + ETH_ALEN > len)
+                               return;
+                       ether_addr_copy(nic->dest_mac_addr, buf + offset);
                }
        }