net: broadcom: bcm4908_enet: fix RX path possible mem leak
authorRafał Miłecki <rafal@milecki.pl>
Wed, 24 Feb 2021 15:18:41 +0000 (16:18 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Feb 2021 17:45:01 +0000 (09:45 -0800)
After filling RX ring slot with new skb it's required to free old skb.
Immediately on error or later in the net subsystem.

Fixes: 4feffeadbcb2 ("net: broadcom: bcm4908enet: add BCM4908 controller driver")
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20210224151842.2419-1-zajec5@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bcm4908_enet.c

index 9be33dc9807218ff3b1354ba2e73345ede624fc0..7983c7a9fca95fe8cc0518f4819d7352768ad09d 100644 (file)
@@ -570,6 +570,7 @@ static int bcm4908_enet_poll(struct napi_struct *napi, int weight)
 
                if (len < ETH_ZLEN ||
                    (ctl & (DMA_CTL_STATUS_SOP | DMA_CTL_STATUS_EOP)) != (DMA_CTL_STATUS_SOP | DMA_CTL_STATUS_EOP)) {
+                       kfree_skb(slot.skb);
                        enet->netdev->stats.rx_dropped++;
                        break;
                }