summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/ezchip/nps_enet.c
AgeCommit message (Collapse)Author
2021-07-20net: ethernet: ezchip: fix error handlingPavel Skripkin
[ Upstream commit 0de449d599594f5472e00267d651615c7f2c6c1d ] As documented at drivers/base/platform.c for platform_get_irq: * Gets an IRQ for a platform device and prints an error message if finding the * IRQ fails. Device drivers should check the return value for errors so as to * not pass a negative integer value to the request_irq() APIs. So, the driver should check that platform_get_irq() return value is _negative_, not that it's equal to zero, because -ENXIO (return value from request_irq() if irq was not found) will pass this check and it leads to passing negative irq to request_irq() Fixes: 0dd077093636 ("NET: Add ezchip ethernet driver") Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-20net: ethernet: ezchip: fix UAF in nps_enet_removePavel Skripkin
[ Upstream commit e4b8700e07a86e8eab6916aa5c5ba99042c34089 ] priv is netdev private data, but it is used after free_netdev(). It can cause use-after-free when accessing priv pointer. So, fix it by moving free_netdev() after netif_napi_del() call. Fixes: 0dd077093636 ("NET: Add ezchip ethernet driver") Signed-off-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2015-12-08net: ezchip: fix address space confusion in nps_enet.cArnd Bergmann
The nps_enet driver happily mixes virtual, physical and __iomem addresses, which are all different depending on the architecture and configuration. That causes a warning when building the code on ARM with LPAE mode enabled: drivers/net/ethernet/ezchip/nps_enet.c: In function 'nps_enet_send_frame': drivers/net/ethernet/ezchip/nps_enet.c:370:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] but will also fail to work for other reasons. In this patch, I'm trying to change the code to use only normal kernel pointers, which I assume is what the author actually meant: * For reading or writing a 32-bit word that may be unaligned when an SKB contains unaligned data, I'm using get_unaligned/put_unaligned() rather than memcpy_fromio/toio. * For converting a u8 pointer to a u32 pointer, I use a cast rather than the incorrect virt_to_phys. * For copying a couple of bytes from one place to another while respecting alignment, I use memcpy instead of memcpy_toio. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-23NET: nps_enet: minor namespace cleanupNoam Camus
We define buf_int_enable in the minimal namespace it is used. Signed-off-by: Noam Camus <noamc@ezchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-23NET: nps_enet: TX done acknowledge.Noam Camus
This is needed for when TX done interrupt is in "level mode". For example it is true for some simulators of this device. Signed-off-by: Noam Camus <noamc@ezchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-23NET: nps_enet: drop control framesNoam Camus
We set controller to drop control frames and not trying to pass them on. This is only needed for debug reasons. Signed-off-by: Noam Camus <noamc@ezchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-23NET: nps_enet: TX done race conditionNoam Camus
We need to set tx_skb pointer before send frame. If we receive interrupt before we set pointer we will try to free SKB with wrong pointer. Now we are sure that SKB pointer will never be NULL during handling TX done and check is removed. Signed-off-by: Noam Camus <noamc@ezchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-23NET: nps_enet: replace use of cause registerNoam Camus
When interrupt is received we read directly from control register for RX/TX instead of reading cause register since this register fails to indicate TX done when TX interrupt is "edge mode". Signed-off-by: Noam Camus <noamc@ezchip.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2015-06-23NET: Add ezchip ethernet driverNoam Camus
Simple LAN device for debug or management purposes. Device supports interrupts for RX and TX(completion). Device does not have DMA ability. Signed-off-by: Noam Camus <noamc@ezchip.com> Signed-off-by: Tal Zilcer <talz@ezchip.com> Acked-by: Alexey Brodkin <abrodkin@synopsys.com> Signed-off-by: David S. Miller <davem@davemloft.net>