From 6c7fce6fa86a110d6455662d823c4e09f8f7be4a Mon Sep 17 00:00:00 2001 From: Sean Wang Date: Sat, 22 Jul 2017 20:45:55 +0800 Subject: net: ethernet: mediatek: avoid potential invalid memory access Potential dangerous invalid memory might be accessed if invalid mac value reflected from the forward port field in rxd4 caused by possible potential hardware defects. So added a simple sanity checker to avoid the kind of situation happening. Signed-off-by: Sean Wang Acked-by: John Crispin Signed-off-by: David S. Miller --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/net/ethernet/mediatek/mtk_eth_soc.c') diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index b3d0c2e6347a..3e3232fd7c05 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -947,6 +947,10 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget, RX_DMA_FPORT_MASK; mac--; + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT || + !eth->netdev[mac])) + goto release_desc; + netdev = eth->netdev[mac]; if (unlikely(test_bit(MTK_RESETTING, ð->state))) -- cgit v1.2.3 From 70dba204a396c1c094749c4ef9bd27d5e8176a08 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 20 Jul 2017 11:06:31 +0100 Subject: net: ethernet: mediatek: Explicitly include linux/interrupt.h The mediatek ethernet driver uses interrupts but does not explicitly include linux/interrupt.h, relying on implicit includes. Fix this so we don't get build breaks as happened for ARM in next-20170720. Signed-off-by: Mark Brown Signed-off-by: David S. Miller --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/ethernet/mediatek/mtk_eth_soc.c') diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 3e3232fd7c05..e588a0cdb074 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "mtk_eth_soc.h" -- cgit v1.2.3