projects
/
GitHub
/
mt8127
/
android_kernel_alcatel_ttab.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge tag 'v3.10.108' into update
[GitHub/mt8127/android_kernel_alcatel_ttab.git]
/
drivers
/
net
/
ethernet
/
xilinx
/
xilinx_emaclite.c
diff --git
a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index b7268b3dae777a1fc29b5aed36f19ec96df462aa..5f5f84ad069756c7cfbf08ab65f0524f1efd7ec4 100644
(file)
--- a/
drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/
drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@
-398,7
+398,7
@@
static int xemaclite_send_data(struct net_local *drvdata, u8 *data,
*
* Return: Total number of bytes received
*/
*
* Return: Total number of bytes received
*/
-static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
+static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data
, int maxlen
)
{
void __iomem *addr;
u16 length, proto_type;
{
void __iomem *addr;
u16 length, proto_type;
@@
-438,7
+438,7
@@
static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
/* Check if received ethernet frame is a raw ethernet frame
* or an IP packet or an ARP packet */
/* Check if received ethernet frame is a raw ethernet frame
* or an IP packet or an ARP packet */
- if (proto_type >
(ETH_FRAME_LEN + ETH_FCS_LEN)
) {
+ if (proto_type >
ETH_DATA_LEN
) {
if (proto_type == ETH_P_IP) {
length = ((ntohl(in_be32(addr +
if (proto_type == ETH_P_IP) {
length = ((ntohl(in_be32(addr +
@@
-446,6
+446,7
@@
static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
XEL_RXBUFF_OFFSET)) >>
XEL_HEADER_SHIFT) &
XEL_RPLR_LENGTH_MASK);
XEL_RXBUFF_OFFSET)) >>
XEL_HEADER_SHIFT) &
XEL_RPLR_LENGTH_MASK);
+ length = min_t(u16, length, ETH_DATA_LEN);
length += ETH_HLEN + ETH_FCS_LEN;
} else if (proto_type == ETH_P_ARP)
length += ETH_HLEN + ETH_FCS_LEN;
} else if (proto_type == ETH_P_ARP)
@@
-458,6
+459,9
@@
static u16 xemaclite_recv_data(struct net_local *drvdata, u8 *data)
/* Use the length in the frame, plus the header and trailer */
length = proto_type + ETH_HLEN + ETH_FCS_LEN;
/* Use the length in the frame, plus the header and trailer */
length = proto_type + ETH_HLEN + ETH_FCS_LEN;
+ if (WARN_ON(length > maxlen))
+ length = maxlen;
+
/* Read from the EmacLite device */
xemaclite_aligned_read((u32 __force *) (addr + XEL_RXBUFF_OFFSET),
data, length);
/* Read from the EmacLite device */
xemaclite_aligned_read((u32 __force *) (addr + XEL_RXBUFF_OFFSET),
data, length);
@@
-632,7
+636,7
@@
static void xemaclite_rx_handler(struct net_device *dev)
skb_reserve(skb, 2);
skb_reserve(skb, 2);
- len = xemaclite_recv_data(lp, (u8 *) skb->data);
+ len = xemaclite_recv_data(lp, (u8 *) skb->data
, len
);
if (!len) {
dev->stats.rx_errors++;
if (!len) {
dev->stats.rx_errors++;