[PATCH net] fm10k: fix potential memleak in fm10k_xmit_frame()
From: Zhang Changzhong
Date: Fri Nov 18 2022 - 07:18:19 EST
The fm10k_xmit_frame() returns NETDEV_TX_OK without freeing skb in error
handling case, add dev_kfree_skb() to fix it. Compile tested only.
Fixes: b101c9626477 ("fm10k: Add transmit and receive fastpath and interrupt handlers")
Signed-off-by: Zhang Changzhong <zhangchangzhong@xxxxxxxxxx>
---
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index 2cca9e8..c7b672a 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -531,8 +531,10 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
/* make sure there is enough room to move the ethernet header */
- if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
+ if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN))) {
+ dev_kfree_skb(skb);
return NETDEV_TX_OK;
+ }
/* verify the skb head is not shared */
err = skb_cow_head(skb, 0);
--
2.9.5